0
I have three Linearlayout inside a Linearlayout
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/l1"
android:layout_alignParentTop="true"></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/l2"
android:layout_alignParentTop="true"></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/l3"
android:layout_alignParentTop="true"></LinearLayout>
</LinearLayout>
And I’m putting one ImageButton
within each of the layout so
if(l==1){
layout1.addView(btCategoria);
layout1.addView(txtCategoria);
Log.e("l1","entrou "+txtCategoria.getText());
l=2;
}else if(l==2){
layout2.addView(btCategoria);
layout2.addView(txtCategoria);
Log.e("l2","entrou "+txtCategoria.getText());
l=3;
}else if(l==3){
layout3.addView(btCategoria);
layout3.addView(txtCategoria);
Log.e("l3","entrou "+txtCategoria.getText());
l=1;
}
btCategoria
and the ImageButton
and the txtCategoria
and a TextView
but the first is not getting on the same straight as the rest
wanted to know why the first image is above the other next
with this gridview will work more he has it android:columnWidth="200dp"
, I wanted to know if there is no way to define it because if you put a specific size will be bad depending on the cell right .
<GridView
android:id="@+id/grid"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="@+id/spinner_widget"
android:cacheColorHint="@color/abc_search_url_text_holo"
android:columnWidth="200dp"
android:gravity="center"
android:numColumns="3"
android:stretchMode="spacingWidth" />
Ever tried to use
android:gravity="top"
in the layout containing the 3?– Luídne
Ilgner, does a Gridview not suit your layout better than mounting that Grid in hand?
– Wakim
and that the grid does not work for every type of cell phone
– Ilgner de Oliveira
I highly recommend you use a
GridView
and let the system control the best way to present the images/information. And, in addition, you will have more control of the layout of each item on your grid. TheGridView
is available from API 1 http://developer.android.com/guide/topics/ui/layout/gridview.html and has several examples of how to implement it!– rsicarelli
go take a look , and that the grid I tried didn’t work
– Ilgner de Oliveira
I made a change in the question , because there is an item there that goes from the problem depending on the mobile , It may get too big or even too small
– Ilgner de Oliveira