How to set the minimum height for a LinearLayout?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to set the minimum height for a LinearLayout?

Postby davechong » Sat Jan 09, 2010 11:56 am

Hi, I have a LinearLayout and a ScrollView, which are given weight of "1" each (equally divided, vertically).

On the top panel (the LinearLayout), there is a TextView (refer to X in the layout XML file below) placed in the center.

On the bottom panel (the ScrollView), there is a list of TextView.

What I'm trying to achieve is that when I switch the orientation from portrait to landscape, I want the top panel to have more height than the bottom panel, so that the top panel will always show the "X" as a whole (without cropping it).

Below is the XML of my layout, would really appreciate it if someone could help me with this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="X"
android:textSize="200.0sp"
/>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value A"
android:textSize="20.0sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value B"
android:textSize="20.0sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value C"
android:textSize="20.0sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value D"
android:textSize="20.0sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value E"
android:textSize="20.0sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value F"
android:textSize="20.0sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Value G"
android:textSize="20.0sp"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
davechong
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jan 09, 2010 10:48 am

Top

Re: How to set the minimum height for a LinearLayout?

Postby jagtap.jj1 » Mon Jan 11, 2010 9:01 am

davechong wrote:What I'm trying to achieve is that when I switch the orientation from portrait to landscape, I want the top panel to have more height than the bottom panel, so that the top panel will always show the "X" as a whole (without cropping it).


U can fix the layout minimum height statically, by using android:minWidth, http://developer.android.com/reference/ ... :minHeight
e.g. android:minWidth="200sp"
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests