[英]Custom Layout doesn't fill Action Bar
我試圖自定義我的操作欄視圖,並定義了自己的視圖。 問題在於它無法正確填充操作欄。
我希望左鏡頭完全位於左側,但我不能! 這是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/iv_logo"
android:layout_width="325dip"
android:layout_height="50dip"
android:layout_centerInParent="true"
android:contentDescription="@string/app_name"
android:clickable="true"
android:src="@drawable/logo"
android:onClick="home_click" />
<ImageView
android:id="@+id/burger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="0dp"
android:background="@null"
android:src="@drawable/lente" />
<ImageView
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="15dp"
android:layout_marginEnd="25dp"
android:layout_marginRight="25dp"
android:background="@null"
android:src="@drawable/lente" />
與其給中央視圖提供固定的寬度/高度,不如將其配置為使其在左右圖像視圖之間完全伸展。 我沒有測試以下代碼,但是它應該按照我描述的方式呈現視圖。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/burger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="0dp"
android:background="@null"
android:src="@drawable/lente" />
<ImageView
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="15dp"
android:layout_marginEnd="25dp"
android:layout_marginRight="25dp"
android:background="@null"
android:src="@drawable/lente" />
<ImageView
android:id="@+id/iv_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:clickable="true"
android:layout_toRightOf="@id/burger"
android:layout_toLeftOf="@id/imageButton"
android:src="@drawable/logo"
android:scaleType="center"
android:onClick="home_click" />
</RelativeLayout>
如果那仍然不能解決問題,則可能是以下問題之一:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.