Hi I'm wondering about how exactly alertdialogs inflate custom xml layouts? In my example, the xml looks fine when I look at it in the eclipse editor however when the alertdialog builds it i looks completly different. (Sadly I do'nt have the reputation to post screenshots)
Heres the xml. The layout gets pushed up so to speak, so the bottom half of linearlayouts take up maybe 2 thirds of the page even though they have a weight of only 0.40 (ps if anyone could tell me an alternative to all these linearlayouts I would be gratefull!!)
Thank You
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.20"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.98"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingTop="32dp"
android:text="Share with..."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#00C5CD" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.02"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#00C5CD" >
</View>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.40"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.50"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.50"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_prev"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/facebook" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_customize_pill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Whatsapp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.50"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_preview3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/whatsapp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_customize_pillsas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Whatsapp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.40"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.50"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_preview4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/email" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_customize_pill4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Email"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.50"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
Ok for what I understood all you need is like a header and under that a grid like layout right?? If I'm right TableLayout might be what you need.
Check this xml and see if it helps you
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingTop="32dp"
android:text="Share with..."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#00C5CD" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#00C5CD"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4">
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
Related
I have a small question about linearlayouts.
Let's say i have, 1 horizontal linearlayout that contains 6 vertical linearlayouts.
I can make all linearslayouts the same width size if i use weightsum=12(of horizontal ll) and layout_weight=2(for vertical ll)
Result :
Now i want the "test1" layout to be 2 or 3 times smaller than the others.
I tried with weightsum=11, and layout_weigth=1(for the test1 layout) and layout_weight=2(for the others). I can't make it work, here is my code...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="11">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
</LinearLayout>
How can i do it?
Thank you.
You need to use : android:layout_width="0dp" for the Linearlayout with the android:layout_weight="1" set as 1.
Now i want the "test1" layout to be 2 or 3 times smaller than the
others
You can reduce the layout weight attribute of test1. to 0.5..
use this layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="6">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test1" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Output
I have problem with my Header I want include all, because I want a footer static.
I try show in :
screens 3.7 show correctly
Screen > 4.0 show incorrectly
My adapter (Only put header full with footer)
if (viewType == TYPE_HEADER) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.header,parent,false); //Inflating the layout
ViewHolder vhHeader = new ViewHolder(v,viewType,context); //Creating ViewHolder and passing the object of type view
return vhHeader; //returning the object created
}
My XML Header.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context="com.onpocket.alcover.Fragment_0_6"
android:orientation="vertical">
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="178dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/contenedor_img_2_1_6_3"
android:id="#+id/l1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.3" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/barra_lateral_img_0_1"
android:layout_marginLeft="16dp"
android:layout_marginTop="38dp"
android:id="#+id/circleView"
android:adjustViewBounds="false" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:background="#af000000"
android:gravity="center_vertical"
android:focusableInTouchMode="false"
android:id="#+id/l3"
android:focusable="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="15dp"
android:layout_height="match_parent" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text="text"
android:textSize="14sp"
android:textStyle="bold"
android:id="#+id/name"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
android:id="#+id/email"
android:textColor="#ffffffff" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView2" >
<LinearLayout
android:orientation="vertical"
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:paddingTop="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView6"
android:src="#drawable/barra_lateral_img_0_2"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_inicio"
android:id="#+id/textView14"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView7"
android:src="#drawable/barra_lateral_img_0_3"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_idiomas"
android:id="#+id/textView15"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="8dp" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView8"
android:src="#drawable/barra_lateral_img_0_4"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_contacto"
android:id="#+id/textView16"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="8dp" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView9"
android:src="#drawable/barra_lateral_img_0_5"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_notificaciones"
android:id="#+id/textView17"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginBottom="10dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout10" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="10dp"
android:layout_height="match_parent"></LinearLayout>
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton6"
android:src="#drawable/barra_lateral_img_0_6"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="facebook"
android:onClick="selectItem" />
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton7"
android:src="#drawable/barra_lateral_img_0_7"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="twitter"
android:onClick="selectItem" />
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton8"
android:src="#drawable/barra_lateral_img_0_8"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="linkedin"
android:onClick="selectItem" />
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton9"
android:src="#drawable/barra_lateral_img_0_9"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="blog"
android:onClick="selectItem" />
<ImageButton
android:layout_width="36dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton10"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="5dp"
android:tag="youtube"
android:onClick="selectItem" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--
<?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="178dp"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/contenedor_img_2_1_6_3" android:scaleType="centerCrop">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:background="#color/opacity"
android:gravity="center_vertical">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:textColor="#ffffff"
android:text="Akash Bangad"
android:textSize="14sp"
android:textStyle="bold"
/>
<!– android:background="#7f000000"
android:singleLine="false"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"–>
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="inicio_texto_empresa"
android:textColor="#ffffffff"
android:layout_marginLeft="16dp"
/>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/barra_lateral_img_0_1"
android:layout_marginLeft="16dp"
android:layout_marginTop="38dp"
android:id="#+id/circleView"
android:adjustViewBounds="false" />
</RelativeLayout>-->
Try to set the weight of the middle Linearlayout to 1 and its height to 0dp. So only your header and your footer have a fixed height and the scrollview will use the remaining space.
As I know, the list view support add footer view, so you can add a custom footer R.layout.drawer_footer view using listview object as below code
View footerView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.drawer_footer, expandableListView, false);
TextView footer = footerView.findViewById(R.id.id_footer_wta_version_information);
expandableListView.addFooterView(footerView);
In my case, I use expandableListView the expandableListView is the same as listView. Hope this way help you
I developed an android app and in which I have create relative layout and I want to display multiple textviews but it can cutoff by vertical and horizontal baseline of relative layout
here is my xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:background="#drawable/single_mode_border"
android:orientation="vertical"
tools:context="com.rabble.MainActivity"
tools:ignore="MergeRootFrame" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.087"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".762"
android:adjustViewBounds="true"
android:src="#drawable/single_player_image" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.237"
android:adjustViewBounds="true"
android:src="#drawable/message_setting_image" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.283"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".283"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".418"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".106"
android:orientation="horizontal" >
</LinearLayout>
<ImageView
android:id="#+id/imageView7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight=".243"
android:src="#drawable/clock_image" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".65"
android:orientation="vertical" >
<TextView
android:id="#+id/timeLeft"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".267"
android:gravity="center_horizontal"
android:text="Time left"
android:textColor="#android:color/black"
android:textSize="12dp" />
<TextView
android:id="#+id/timerText"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".732"
android:gravity="center"
android:text="TextView"
android:textColor="#android:color/black"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".156" >
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".843"
android:orientation="vertical" >
<TextView
android:id="#+id/currentPoint"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".315"
android:gravity="center_horizontal"
android:text="Current points"
android:textColor="#android:color/black"
android:textSize="12dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".684" >
<ImageView
android:id="#+id/imageView8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".274"
android:adjustViewBounds="true"
android:src="#drawable/coin_image" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".118" >
</LinearLayout>
<TextView
android:id="#+id/scoreText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_weight=".370"
android:background="#drawable/textview_white_rectangle_border"
android:gravity="center"
android:textColor="#android:color/black"
android:textSize="20dp"
android:text="0" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.237" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".283"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.187"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".540"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".053"
android:orientation="horizontal" >
</LinearLayout>
<ImageView
android:id="#+id/nextbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight=".062"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/white_arrow"
android:text="Button" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.884" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".460" >
<LinearLayout
android:id="#id/fillInBlanksLinear"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".906"
android:gravity="center" >
</LinearLayout>
<ImageView
android:id="#+id/checkView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".093"
android:src="#drawable/game_check_right"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/textrelative"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.441"
android:layout_gravity="fill">
</RelativeLayout>
You should use a ScrollView at the root level.Get more information from here.
http://developer.android.com/reference/android/widget/ScrollView.html
Also I see that you have got a lot of linear layouts .They should be clubbed together into lesser number of RelativeLayouts.
I have a problem with my XML file.
I want to have a layout which places 3 buttons on the whole screen. If I use 4 inch device and fixed dp or dip values I can get what I want. But if I use 10 inch tablet the layout looks small.
Here is my code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="vertical"
android:padding="10dip"
tools:context=".Main" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="DOBRODOŠLI!"
android:textSize="25sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="33"
android:orientation="vertical" >
<Button
android:id="#+id/bCV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/cv"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="33"
android:orientation="vertical" >
<Button
android:id="#+id/bApplicationLetter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="#string/application_letter"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="33"
android:orientation="vertical" >
<Button
android:id="#+id/bEmail"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/email"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="33"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/cv"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="33"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Motivacijsko"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="33"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/email"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
This is how I want my layout to look:
http://i.imgur.com/dLFNcJB.png
Thanks in advance! :D
Main.xml file
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="100dp"
android:layout_below="#+id/rel2" >
<LinearLayout
android:id="#+id/llData"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="8"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
Here, i am adding below xml file into linearlayout llData ..
inflate_page.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:weightSum="2"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/grid_default" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/txtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtAddField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="TextView" />
</LinearLayout>
inflate layout in another using below code:
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View menuLayout = inflater.inflate(R.layout.inflate_page, llData,
true);
Below image is what i want:
Below image is my actual output:
please guide me how to solve this problem of weight. layout not showing properly.
The problem is with the ScrollView. Try to add to the layout setting "fillViewport:true"
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="100dp"
android:layout_below="#+id/rel2"
android:fillViewport="true" <---
>
This way the Scrollview will always fill the screen and solve your problem.
For your concern #Segi
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:weightSum="2"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imgImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/txtLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtAddField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16dp"
android:text="TextView" />
</LinearLayout>
</LinearLayout>