android-layout-weight

Replacement for the linearLayout weights mechanism

蹲街弑〆低调 提交于 2019-12-20 09:54:24
问题 Background: Google suggests to avoid using nested weighted linearLayouts because of performance. using nested weighted linearLayout is awful to read, write and maintain. there is still no good alternative for putting views that are % of the available size. Only solutions are weights and using OpenGL. There isn't even something like the "viewBox" shown on WPF/Silverlight to auto-scale things. This is why I've decided to create my own layout which you tell for each of its children exactly what

android:layout_height 50% of the screen size

会有一股神秘感。 提交于 2019-12-18 10:26:54
问题 I just implemented a ListView inside a LinearLayout, but I need to define the height of the LinearLayout (it has to be 50% of the screen height). <LinearLayout android:id="@+id/widget34" android:layout_width="300px" android:layout_height="235px" android:orientation="vertical" android:layout_below="@+id/tv_scanning_for" android:layout_centerHorizontal="true"> <ListView android:id="@+id/lv_events" android:textSize="18sp" android:cacheColorHint="#00000000" android:layout_width="fill_parent"

Android Linear Layout Weight Programmatically

穿精又带淫゛_ 提交于 2019-12-17 19:07:09
问题 I want to add three linear layouts to an activity programatically each of same width. the problem is i am not able to set the weights of these layouts programmatically. I could do this within xml, but I want to do this in program. here is what I want: 回答1: Here its the solution LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, 100); lp.weight = 1; See Full Solution LinearLayout ll1, ll2, ll3; /* Find these LinearLayout by ID i.e ll1=(LinearLayout)findViewById(R.id.ll1); */

Android how to display 2 listviews in one activity one after the other

☆樱花仙子☆ 提交于 2019-12-17 02:35:09
问题 I have used this code to display 2 list view one on top of the other. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="#f00" > </ListView> <ListView android:id="@+id/listView2" android:layout_width="match_parent"

How to set layout_weight attribute dynamically from code?

别说谁变了你拦得住时间么 提交于 2019-12-17 01:40:02
问题 How can I set the value for the attribute layout_weight for button in android dynamically from java code ? 回答1: You can pass it in as part of the LinearLayout.LayoutParams constructor: LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f ); YOUR_VIEW.setLayoutParams(param); The last parameter is the weight. 回答2: Use LinearLayout.LayoutParams: LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams

Columns in a TableRow divided using weights & weightsums not spacing elements properly

删除回忆录丶 提交于 2019-12-13 07:16:40
问题 I've been assigned to create an activity that displays table of changes made to the app by version. The table has four columns, Id, Type, Description, and Version. To do this, I placed a TableLayout in a scrollView. Then, I have a template for the TableRows, that are inflated dynamically at Runtime. The column widths should stay static; they can overflow in height but not width. To achieve this, I tried using the weight & weight: sum property of the column and row container respectively. I

How to set layout_weight programmatically?

[亡魂溺海] 提交于 2019-12-12 18:31:13
问题 Disclaimer: AFAIK This question has no answer so far for XAMARIN ANDROID . It has been answered multiple times for Android/Java. My problem is that I have no constructor overload for GridLayoutParams that takes the layout_weight as a parameter... The following is the XML I'm trying to replicate by code: android:layout_width="0sp" android:layout_height="wrap_content" android:layout_weight="1" Not setting layout_weight makes the control (a checkbox) simply invisible. Here is where I am with the

Images disappear when read more button is clicked?

我们两清 提交于 2019-12-12 07:05:04
问题 I created a ScrollView and added two LinearLayouts inside one big LinearLayout and have given weights for those.The problem is that it shows my images of the image slider at initial state and once I clicked read more the images dissapear except for the dot indicators.Once again when I press read less the images of the image slider appear.Two screenshots and the codes are given below.How can I solve it? FragmentSL.xml <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns

Android Inside Custom ListView, TextView Weight property not working

纵饮孤独 提交于 2019-12-12 05:12:32
问题 I have a custom listView. The listview data are setting by some textview horizontally for each rows. In main layout I have same number of textView for setting the title of those columns. My problem is, the main layout working fine with the weight property. But the custom value setting layout for listview which contains the textview is not working with the weight property. Main Layout : (Weight property working correctly) <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

How can I prevent my bottom toolbar with 3 images from being stretched out?

China☆狼群 提交于 2019-12-12 03:28:03
问题 I have a bottom layout with three images. I want them to be equally distributed. To do this, I used the layout_weight xml property. But the visual representation of them is awful – the images are all stretched out The images' dimension is 32*32. The layout code for this particular toolbar is: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap