【发布时间】:2016-05-12 05:15:30
【问题描述】:
您好,我正在学习 Android。
这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.aidsdruginformation.DetailActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:elevation="4dp"
android:padding="8dp"
android:text="ApprovalStatus"
android:textAlignment="center" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:elevation="4dp"
android:padding="8dp"
android:text="FDA-approved"
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:elevation="4dp"
android:padding="8dp"
android:text="ApprovalStatus"
android:textAlignment="center" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:elevation="4dp"
android:padding="8dp"
android:text="GDA-approved"
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>
</ScrollView>
用户界面截图:
我希望我的 UI 看起来如何:
为什么第二个LinearLayout 没有显示?
难道我做错了什么?
在使用layout_width 时,父元素是否应该具有固定尺寸?
请指教..
链接到我的回购: https://github.com/MukundPradeep/AidsDrugInformation
【问题讨论】:
-
在滚动视图上使用
android:fillViewport="true" -
以上评论为答案。
-
我已经添加了这个并将 android:weightSum="2" 设置为我的父 LinearLayout.. 第二个内部 LinearLayout 仍然没有显示
-
显示截图,你想要什么?
-
已经用需要的 UI 进行了编辑。水平元素必须对齐。页面必须是可滚动的。我不想使用 ListView
标签: android xml android-layout android-studio scrollview