android - 填充不适用于 Android

标签 android xml layout

以下代码来 self 为我的应用程序设计的布局。问题是,Button 与 PlainText 框重叠,因此我在按钮代码中添加了填充,如下所示,但预览仍显示 Button 与文本框重叠。什么是问题?我错过了什么吗?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100"
android:padding="25dp" >

<ScrollView 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="30"
>

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
>
<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<EditText
    android:id="@+id/editText4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<EditText
    android:id="@+id/editText5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />

<EditText
    android:id="@+id/editText6"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" />
</LinearLayout>
</ScrollView>

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:layout_weight="40">
<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingTop="20dp"
    android:text="Button" />
</LinearLayout>

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="30"
    android:orientation="vertical">
<AnalogClock
    android:id="@+id/analogClock1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</LinearLayout>

感谢您的帮助!

最佳答案

您似乎想分开两个 View 。您应该在您的 View 中使用边距而不是填充。

android:layout_marginLeft="10dp"

你可以根据需要在左、右、上、下留边距。

关于android - 填充不适用于 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11816274/

相关文章:

java - 使用循环删除某些布局 View

iOS LayoutIfNeeded() 未返回正确的大小

android - 二值图像中的 FindContours 和 CountObject

java - 如何在 SplashScreen 之后启动另一个 Activity。启动画面在给定的计时器之后崩溃

c# - 无需在客户端安装 mysql 连接器即可将应用程序转换为工作

xml - 在线性布局中居中按钮

java - 我想在长按 "+"或 "-"按钮时继续增加/减少计数器.... Android setOnLongClickListener

android - 如何在 Android 的谷歌纸板 View 中播放视频?

xml - 如何使 xsd 元素扩展另一个

html - 在 div 下推送列表