Java 上下布局
我正在尝试在Android应用程序中创建此页面: 现在,我以以下布局结束:Java 上下布局,java,android,layout,Java,Android,Layout,我正在尝试在Android应用程序中创建此页面: 现在,我以以下布局结束: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:orientation="vertical">
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:text="My App"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="36sp"
android:textStyle="bold|italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/white"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="24dp"
android:elevation="10dp"
app:cardCornerRadius="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</FrameLayout>
问题是,当键盘聚焦时,我得到了这个结果,将adjustResize放在清单中:
你知道如何:
1) 当键盘聚焦时,避免覆盖输入
2) 像第一个图形一样放置按钮(位于底部边距上方)
如果您对如何改进xml有任何建议,那就太好了,因为我是android xml新手
提前谢谢你1)如果清单中没有adjustSize
,我没有任何问题
)要创建平面布局而不是分层布局(这对您的应用程序性能更好)您可以使用ScrollView
将整个布局包装起来,我在其顶部使用嵌套的滚动视图,这只是片段布局,因此我无法使用ScrollView。我已经试着不把所有的东西都放在线性布局中,效果很好,所以我认为是因为线性布局的问题。如果我不使用调整大小按钮,键盘就会覆盖它,这就是为什么我使用了标志。我很想使用约束布局,但我不知道如何设置创建背景的两个布局(一个蓝色和一个白色)。您知道如何在约束布局中设置50%的布局吗?
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:orientation="vertical">
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:text="My App"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="36sp"
android:textStyle="bold|italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/white"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="24dp"
android:elevation="10dp"
app:cardCornerRadius="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/default_text_layout5"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/default_text5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:theme="@style/AppTheme" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
</FrameLayout>