我有一個工具欄,左側有一個圖標,右側有一個圖標。在中心將是一個文本視圖?以下是我目前的佈局設置。如何使圖像按鈕顯示和工具欄的文本視圖中心?
現在的問題是imagebutton圖像沒有出現只是一個小的銀色矩形出現和文本視圖單詞對齊而不是中心。另一件事情是如何控制圖標文本視圖的高度,使它們看起來相似?右側的最後一個圖標也不會出現。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottomToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/primary"
android:minHeight="@android:dimen/notification_large_icon_height">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pinButton"
android:layout_centerHorizontal="true"
android:layout_gravity="left"
android:drawable="@drawable/basgreen"
android:clickable="true"/>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="TEST"
android:background="@color/primary"
android:textColor="#ffffff"
android:layout_gravity="center"
android:padding="10dip"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/pinButton3"
android:layout_centerHorizontal="true"
android:layout_gravity="right"
android:drawable="@drawable/basgreen"
android:clickable="true"/>
</android.support.v7.widget.Toolbar>
以下是迄今爲止輸出的最終截圖。
它就像一個圖像是局部的,另一個是如此之大,texview丟失了。 – user5313398
我必須設置ImageButton的寬度和高度,以便它保持機智嗎? – user5313398
如果我用30dp作爲寬度和高度是合理的還是太小,你需要設置'layout_width'和'layout_height'以適應'ImageButton' –