I have an up with 3 buttons bat the bottom. When i test it on the emulator, the full screen appears. when i test it on my device, the buttons below does not show. it's like the resolution is incorrect. here is my xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#raw/mexicanbg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonbacksubreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/back_button"
android:onClick="back" />
<TextView
android:id="#+id/textViewreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="45dp"
android:text="#string/reclist"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="382dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="362dp" >
<Button
android:id="#+id/buttonRecipes"
android:layout_width="108dp"
android:layout_height="wrap_content"
android:background="#drawable/menu_xrecipes"
android:onClick="recipe"
android:text="#string/rec" />
<Button
android:id="#+id/buttonGroList"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:background="#drawable/menu_xgrocery"
android:onClick="grocerylist"
android:text="#string/grolist" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/menu_xmore"
android:text="#string/more" />
</LinearLayout>
</LinearLayout>
EDIT:
New Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#raw/mexicanbg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonbacksubreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/back_button"
android:onClick="back" />
<TextView
android:id="#+id/textViewreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="45dp"
android:text="#string/reclist"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="382dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="362dp" >
<Button
android:id="#+id/buttonRecipes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xrecipes"
android:onClick="recipe"
android:text="#string/rec" />
<Button
android:id="#+id/buttonGroList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xgrocery"
android:onClick="grocerylist"
android:text="#string/grolist" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xmore"
android:text="#string/more" />
</LinearLayout>
</LinearLayout>
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#raw/mexicanbg"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonbacksubreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/back_button"
android:onClick="back" />
<TextView
android:id="#+id/textViewreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="45dp"
android:text="#string/reclist"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/real1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollX="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#+id/real1" >
<Button
android:id="#+id/buttonRecipes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xrecipes"
android:onClick="recipe"
android:text="#string/rec" />
<Button
android:id="#+id/buttonGroList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xgrocery"
android:onClick="grocerylist"
android:text="#string/grolist" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xmore"
android:text="#string/more" />
</RelativeLayout>
</RelativeLayout>
Replace last linear layout by relative layout and specify android:layout_alignParentBottom="true"
and also make RelativeLayout as your root Layout
Try this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#raw/mexicanbg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonbacksubreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:background="#drawable/back_button"
android:onClick="back" />
<TextView
android:id="#+id/textViewreclist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="45dp"
android:text="#string/reclist"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp" >
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="200dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/buttonRecipes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xrecipes"
android:onClick="recipe"
android:text="#string/rec" />
<Button
android:id="#+id/buttonGroList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xgrocery"
android:onClick="grocerylist"
android:text="#string/grolist" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xmore"
android:text="#string/more" />
</LinearLayout>
</LinearLayout>
I found the answer ... The problem is not with t he buttons.. it is with my ListView. I did not put weight on my listview. Here is my final xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#raw/mexicanbg">
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal"
android:background="#drawable/xpage_label">
<TextView
android:id="#+id/textViewrecipe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_marginBottom="10dp"
android:text="#string/rec"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
</LinearLayout>
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xrecipes"
android:onClick="recipe" />
<Button
android:id="#+id/buttonGroList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xgrocery"
android:onClick="grocerylist" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/menu_xmore" />
</LinearLayout>
</LinearLayout>
Related
I just want to use multiple layout in a single xml file.I have attached my code below. In that there will be an absolute layout that should be under Horizontal scroll. As a beginner I don't know how to implement it
need your help friends..
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/aagr_background2"
android:orientation="vertical" >
<fragment
android:id="#+id/adview153613"
android:name="com.sentientit.theiWedplanner.Fragadmob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#drawable/aanavigationbar" >
<Button
android:id="#+id/back"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginTop="3dp"
android:layout_x="8px"
android:layout_y="3px"
android:background="#drawable/custom_btn_breaker_bay"
android:text="Back"
android:textColor="#ffffff"
android:textSize="20sp" />
<Button
android:id="#+id/home"
android:layout_width="50px"
android:layout_height="30px"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/back"
android:layout_marginRight="46dp"
android:background="#drawable/home1"
android:paddingBottom="12px"
android:paddingTop="10px"
android:visibility="gone" />
</RelativeLayout>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="61dp" >
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="61dp"
android:layout_x="120dp"
android:layout_y="35dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="38dp"
android:layout_y="30dp"
android:text="- Kid Seated"
android:textColor="#000000"
android:textSize="13dp"
android:typeface="serif" >
</TextView>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="6dp"
android:layout_y="28dp"
android:src="#drawable/kid" >
</ImageView>
</AbsoluteLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="437dp"
android:layout_y="3dp"
android:src="#drawable/add11_table" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="4dp"
android:text="Line"
android:textSize="20sp" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="128dp"
android:layout_y="4dp"
android:text="circle"
android:textSize="20sp" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="212dp"
android:layout_y="6dp"
android:text="vshape"
android:textSize="20sp" />
</AbsoluteLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
Thank you in advance
Not sure whether your looking for this alignment but i just gave a shot..... whenever you wish to fix layout at the bottom of screen make sure you use weight property i.e if you want fix button at the bottom of screen then put android:layout_height = "0dp" and layout_weight="1" for other major layout in the xml and to button which has to be fixed at the bottom use android:layout_height="wrap_content" and layout_weight = "0" that's all is the trick (sorry if i have made it hard to understand... just simply saying play with weight and height property)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical" >
<fragment
android:id="#+id/adview153613"
android:name="com.sentientit.theiWedplanner.Fragadmob"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/back"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="8dp"
android:layout_marginTop="3dp"
android:layout_x="8px"
android:layout_y="3px"
android:text="Back"
android:textColor="#ffffff"
android:textSize="20sp" />
<Button
android:id="#+id/home"
android:layout_width="50px"
android:layout_height="30px"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/back"
android:layout_marginRight="46dp"
android:paddingBottom="12px"
android:paddingTop="10px"
android:visibility="gone" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</HorizontalScrollView>
</ScrollView>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" >
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="61dp"
android:layout_x="120dp"
android:layout_y="35dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="38dp"
android:layout_y="30dp"
android:text="- Kid Seated"
android:textColor="#000000"
android:textSize="13dp"
android:typeface="serif" >
</TextView>
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="6dp"
android:layout_y="28dp" >
</ImageView>
</AbsoluteLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="437dp"
android:layout_y="3dp" />
<Button
android:id="#+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="48dp"
android:layout_y="4dp"
android:text="Line"
android:textSize="20sp" />
<Button
android:id="#+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="128dp"
android:layout_y="4dp"
android:text="circle"
android:textSize="20sp" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="212dp"
android:layout_y="6dp"
android:text="vshape"
android:textSize="20sp" />
</AbsoluteLayout>
</LinearLayout>
Yes, you can use use multiple layouts in single XML using the <include>.
Here is a example for that:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/app_background"
android:orientation="vertical" >
<include layout="#layout/actionbar_main" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/img_rest_pic"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight=".35"
android:src="#drawable/upload_image" />
</LinearLayout>
</LinearLayout>
The actionbar_main.xml file is in different XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#drawable/navbar_txt"
android:orientation="vertical" >
<ImageButton
android:id="#+id/ibtn_action_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:background="#null"
android:src="#drawable/navbar_back" />
<ImageButton
android:id="#+id/ibtn_action_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/ibtn_action_back"
android:layout_marginRight="5dp"
android:background="#null"
android:src="#drawable/nacbar_setting" />
<View
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#color/white" />
</RelativeLayout>
I have a LinearLayout that has a number of text fields and an ImageView to the right of the LinearLayout. However the position of the image is never fixed and shifts depending on the content of the TextView fields. How do I solve this problem ? I have tried manipulating android:layout_gravity but that does not give me a solution. I would just like my image to dock itself at the right regardless of the content of the TextViews. Here is my layout file. Any pointers or a solution would be most appreciated.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="144dp"
android:orientation="vertical"
android:layout_gravity="left"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/date_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date_of_birth" />
<TextView
android:id="#+id/date_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/place_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/place_of_birth" />
<TextView
android:id="#+id/place_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/height_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/height" />
<TextView
android:id="#+id/height"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/blood_type_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/blood_type" />
<TextView
android:id="#+id/blood_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/member_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
/>
</LinearLayout>
Use RelativeLayout in your outermost layout. You can set the image to display on the right and centre vertically.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="144dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/name_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/date_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date_of_birth" />
<TextView
android:id="#+id/date_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/place_of_birth_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/place_of_birth" />
<TextView
android:id="#+id/place_of_birth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/height_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/height" />
<TextView
android:id="#+id/height"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/blood_type_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/blood_type" />
<TextView
android:id="#+id/blood_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/member_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
I have a listview with a custom adapter. I am trying to show subtext under an item. This is the xml I am using. The problem is that both TextView merge together. What can I do?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:paddingLeft="10dp" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_below="#id/tijd"/>
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/tijd" />
</RelativeLayout>
You can try it like below,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
<TextView
android:id="#+id/tijd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_toRightOf="#+id/type"
android:text="abcde" />
<TextView
android:id="#+id/sub"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tijd"
android:layout_toRightOf="#+id/type"
android:text="abcd" />
</RelativeLayout>
And your output will be as,
use layout below and centerhorizontal for sub
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tijd"
android:centerHorizontal="true"
android:text="abcd" />
I think, you have to remove the centerInParent from the sub.
Try this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="title" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="subtitle" />
</LinearLayout>
</LinearLayout>
Try this :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:text="Heading" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tijd"
android:layout_centerInParent="true"
android:text="Subheading" />
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/tijd"
android:background="#drawable/ic_launcher" />
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/type"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/tijd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="adad" />
<TextView
android:id="#+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="adad" />
</LinearLayout>
</LinearLayout>
Hope it will work.
I want to center horizontally and vertically block L3 on this image, can you help me with the layout structure to use. ON the right side is current structure of the menu. Thanks.
Here is the layout.xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/BaseLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/mainmenu_background" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_background" />
<LinearLayout
android:id="#+id/l1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- Top menu -->
<LinearLayout
android:id="#+id/l2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/TopMenuHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/main_menu_background_header"
android:gravity="left"
android:orientation="horizontal"
android:visibility="visible" >
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:src="#drawable/logo" />
<LinearLayout
android:id="#+id/TopRightButtonsHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:visibility="visible" >
<RelativeLayout
android:id="#+id/sinscrire"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/login_registerbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_sinscrire_button" />
<TextView
android:id="#+id/sinscrire_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/cpr_sinscrite_title_text"
android:textColor="#color/cpr_menubutton_black"
android:textSize="#dimen/cpr_small_menubutton_title_text_size"
android:textStyle="bold|italic" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/connexion"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/login_loginbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_logout_button" />
<TextView
android:id="#+id/connexion_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/cpr_connexion_title_text"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_small_menubutton_title_text_size"
android:textStyle="bold|italic" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<!-- End of Top menu -->
<!-- Middle menu -->
<LinearLayout
android:id="#+id/l3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/MiddleMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" >
<LinearLayout
android:id="#+id/MiddleLeftButtonsHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal"
android:visibility="visible" >
<RelativeLayout
android:id="#+id/Parametres"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/optionsmenu_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_options_button" />
<LinearLayout
android:id="#+id/options_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="left"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/options_icon" />
<TextView
android:id="#+id/parametres_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cpr_parametres_title_text"
android:textColor="#color/cpr_menubutton_black"
android:textSize="#dimen/cpr_small_menubutton_title_text_size"
android:textStyle="bold|italic" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/Aide"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/optionsmenu_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_help_button" />
<LinearLayout
android:id="#+id/help_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="left"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/help_icon" />
<TextView
android:id="#+id/aide_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cpr_aide_title_text"
android:textColor="#color/cpr_menubutton_black"
android:textSize="#dimen/cpr_small_menubutton_title_text_size"
android:textStyle="bold|italic" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/MiddleRightButtonsHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#id/MiddleLeftButtonsHolder"
android:orientation="horizontal"
android:visibility="visible" >
<RelativeLayout
android:id="#+id/Caisse"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/cashiericon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_cashier_button" />
<LinearLayout
android:id="#+id/caisse_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="left"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/cashier_icon" />
<TextView
android:id="#+id/caisse_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cpr_caisse_title_text"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_small_menubutton_title_text_size"
android:textStyle="bold|italic" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<!-- End of Middle menu -->
<!-- Main menu -->
<RelativeLayout
android:id="#+id/MainMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/MiddleMenu"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" >
<ImageView
android:id="#+id/main_menu_black_rect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:scaleType="fitXY"
android:src="#drawable/main_menu_black_rect" />
<RelativeLayout
android:id="#+id/play_for_real"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="20dp" >
<ImageButton
android:id="#+id/realmoneybutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitStart"
android:src="#drawable/main_menu_play_for_real_button" />
<ImageView
android:id="#+id/play_for_real_img_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/realmoneybutton"
android:layout_alignRight="#id/realmoneybutton"
android:background="#color/transparent"
android:src="#drawable/main_menu_play_for_real_button_icon" />
<LinearLayout
android:id="#+id/play_for_money_text_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/play_for_real_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cpr_play_for_real_title_text"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_menubutton_title_text_size"
android:textStyle="bold" />
<TextView
android:id="#+id/play_for_real_desc"
android:layout_width="221dp"
android:layout_height="wrap_content"
android:text="#string/cpr_play_for_real_title_desc"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_menubutton_desc_text_size" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/play_for_fun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/play_for_real"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp" >
<ImageButton
android:id="#+id/playmoneybutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_play_for_fun_button" />
<ImageView
android:id="#+id/play_for_fun_img_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/playmoneybutton"
android:layout_alignRight="#id/playmoneybutton"
android:background="#color/transparent"
android:src="#drawable/main_menu_play_for_fun_button_icon" />
<LinearLayout
android:id="#+id/play_for_fun_text_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/play_for_fun_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cpr_play_for_fun_title_text"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_menubutton_title_text_size"
android:textStyle="bold" />
<TextView
android:id="#+id/play_for_fun_desc"
android:layout_width="221dp"
android:layout_height="wrap_content"
android:text="#string/cpr_play_for_fun_title_desc"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_menubutton_desc_text_size" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/tutoriel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/play_for_fun"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp" >
<ImageButton
android:id="#id/previewbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#color/transparent"
android:scaleType="fitXY"
android:src="#drawable/main_menu_tutorial_button" />
<TextView
android:id="#+id/tutoriel_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="#string/cpr_tutoriel_title_text"
android:textColor="#color/cpr_menubutton_white"
android:textSize="#dimen/cpr_menubutton_title_text_size"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<!-- End of Main menu -->
</LinearLayout>
<!-- End of Main Container -->
</RelativeLayout>
Here is a Linear Layout with a Relative Layout centered inside.
Move your code from the "l3" layout to the "l4" layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/l1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/l2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#56a"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="l2" />
</LinearLayout>
<RelativeLayout
android:id="#+id/l3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#a56" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="l3" />
<RelativeLayout
android:id="#+id/l4"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#5a6" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="l4" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
I'm trying to use one date picker and two time picker in the same layout, but only the first one in layout is being displayed. I'm sure something must be wring with my layout but haven't found the error yet.
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B5B5B5"
android:orientation="vertical" >
<include layout="#layout/actionbar_layout" />
<LinearLayout
android:id="#+id/new_conference_date"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_start"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_start_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_start_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_start_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_end_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_end_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_end_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
</LinearLayout>
try this one:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B5B5B5"
android:orientation="vertical" >
<include layout="#layout/actionbar_layout" />
<LinearLayout
android:id="#+id/new_conference_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="date:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_start_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_start_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_start_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
<LinearLayout
android:id="#+id/new_conference_end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f8f9fe"
android:orientation="horizontal" >
<TextView
android:id="#+id/new_conference_end_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="end:"
android:textColor="#000000" />
<TextView
android:id="#+id/new_conference_end_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#000000" />
<Button
android:id="#+id/new_conference_end_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
I just changed inner LinearLayouts height to wrap_content
You have three LinearLayout with match_parent in layout_width without a weight.
Try adding the next line to those LinearLayout's
android:layout_weight="1"