当前位置: 动力学知识库 > 问答 > 编程问答 >

Multiple linear layouts in Android app development (xml)

问题描述:

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="DOBRODOLI!"

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: