编辑(布局代码):
<FrameLayout 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=".ProfileChooseActivity"
android:scrollIndicators="none"
android:background="@drawable/bg_run4">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<LinearLayout
android:orientation="vertical"
android:layout_width="233dp"
android:layout_height="159dp"
android:layout_gravity="start|bottom"
android:layout_margin="10dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/profileNameEditText"
android:layout_margin="10dp"
android:backgroundTint="#97f8720b"
android:hint="@string/profile_name"
android:textCursorDrawable="@null"
android:layout_marginTop="20dp"
android:textColor="#3d3131"
android:textAlignment="center"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enter_profile"
android:id="@+id/enterProfileButton"
android:layout_gravity="center_horizontal"
android:background="#97f8720b"
android:singleLine="false"
android:clickable="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
</LinearLayout>
</FrameLayout>
答案 0 :(得分:1)
我按照你的描述复制了布局文件,一切正常。可能是你的布局有问题。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textAlignment="center"/>
</LinearLayout>
</FrameLayout>
答案 1 :(得分:0)
textAlignment 的界面使用 gravity 作为center_horizontal 就我而言,这是可行的