How can I fill the screen with 2 horizontal colors, such that the down one will get 10% of the screen? (like a toolbar)?
I'm trying modify the Linear Layout example to:
<?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="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="green"
android:gravity="center_horizontal"
android:background="#00aa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="blue"
android:gravity="center_horizontal"
android:background="#0000aa"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="single row"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
but if change the
android:layout_height="fill_parent"
for
android:layout_height="wrap_content"
on the down "panel"(is it a panel?) the text is not shown complete.
You will want to use fill_parent and not wrap content, and what should work is if the upper part has a weight of 9 and the lower part a weight of 1. The weight should work as a percentage of the total weights, so 9+1 = 10 and 1/10 is 10%.
精彩评论