如何用 2 种水平颜色填充屏幕,使下方的颜色占屏幕的 10%? (像一个工具栏)?
我正在尝试修改 Linear Layout example到:
<?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>
但是如果改变
android:layout_height="fill_parent"
对于
android:layout_height="wrap_content"
在下面的“面板”(是面板吗?)上,文本显示不完整。
最佳答案
你会想要使用 fill_parent 而不是包装内容,如果上半部分的权重为 9 而下半部分的权重为 1,则应该起作用。重量应该按总重量的百分比工作,所以9+1 = 10,1/10 是 10%。
关于android - 如何填充 10% 的 Android 屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3205554/