我試圖在我的應用程序中實現自定義工具欄。我想在左邊有1個圖像和1個文本視圖,中間有1個文本視圖,最後是1個文本視圖。在預覽模式下,它看起來像預期一樣: 然而,當我虛擬設備上啓動我的應用程序,所有的意見都對準啓動:
工具欄內容在預覽模式下看起來不同於仿真器
我的代碼:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
tools:context=".OptionListActivity">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:weightSum="3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/btn_star_big_on"
android:id="@+id/imageView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/nameSurname"
android:text="June Office"
android:textColor="@android:color/white"
android:textAlignment="viewStart"
android:layout_weight="1"
android:layout_marginStart="5dp" />
<TextView
android:text="Dec 19, 12:47 PM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/dateTime"
android:textColor="@android:color/white"
android:textAlignment="center"
android:layout_weight="1"/>
<TextView
android:text="415-555-1212"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/number"
android:textColor="@android:color/white"
android:textAlignment="viewEnd"
android:layout_weight="1"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
我需要做什麼改變以獲得預期的結果?也許有人可以解釋我爲什麼它看起來不錯,在預覽模式和不正確的模擬器...
不幸的是,這沒有奏效,所以問題依然存在... –