android - 如何填充 10% 的 Android 屏幕?

标签 android

如何用 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/

相关文章:

android - 如何复用组件?

android - Xamarin - Visual Studio - 尽管已安装,但 Android 编译版本不存在

android - AChartEngine条形图的跨设备兼容性问题

android - 如何在 Android 中实现分页 ListView

java - 如何在函数中返回 GPS 给出的值

android - 如何使用 adb 命令在 android 中播放一个音频文件?

java - 我如何在我的java游戏中保存玩家姓名和得分?

Android 共享元素转换 : Transforming an ImageView from a circle to a rectangle and back again

java - 安装 XamarinInstaller.exe 时出现问题

android - 错误权限 ACCESS_FINE_LOCATION