我正在尝试在 Android 中创建一个工具栏,它的高度是普通工具栏的 2x,并且有一个 EditText
在下半部分。
目前,我有 XML 代码(注意 android:layout_height="128dp"
):
<RelativeLayout
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">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:title="Messages"
android:titleTextColor="@color/windowBackground"
android:background="@color/buttonBackground"
android:layout_height="128dp"
android:layout_width="match_parent"
android:minHeight="?android:attr/actionBarSize"
android:gravity="bottom" />
<fragment
android:id="@+id/no_activity_fragment"
class="com.ohmd.ohmd.ui.main.MainActivityListFragment"
android:name="com.ohmd.ohmd.ui.main.MainActivityListFragment"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
所以我遇到的一些问题:
(a) 当高度设置为
"?android:attr/actionBarSize"
时,如何让“消息”与顶部对齐? ?(b) 标题上移后,如何添加
EditText
在下半部分查看?
最佳答案
得到它:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:title="Messages"
android:titleTextColor="@color/windowBackground"
android:background="@color/buttonBackground"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:gravity="center" />
<RelativeLayout
android:orientation="vertical"
android:background="@color/buttonBackground"
android:layout_height="?android:attr/actionBarSize"
android:layout_below="@+id/toolbar"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:gravity="center">
<EditText
android:layout_margin="10dp"
android:id="@+id/tvSection"
android:background="@color/buttonBackgroundSelected"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"/>
</RelativeLayout>
关于java - 如何在底部使用 EditText 在 Android 中创建扩展工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40411897/