【发布时间】:2019-01-19 18:07:24
【问题描述】:
我正在创建如下标题栏,“主页”和“抽屉”图标将根据案例设置可见/消失。 如何使文本视图不与“主页”/“抽屉”图标重叠??
这就是我的代码所具有的,我手动将文本视图边距设置为主页和抽屉图标,但是,当主页/抽屉图标被隐藏时,文本仍然保持主页按钮出现.如何根据可用空间设置文本视图完美换行?
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton
android:id="@+id/actionbar_backbutton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="?attr/actionBarItemBackground"
android:scaleType="centerInside"
android:src="@drawable/ic_arrow_back_black_24dp" />
<TextView
android:id="@+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="105dp"
android:layout_toRightOf="@id/actionbar_backbutton"
android:background="?attr/actionBarItemBackground"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="@string/Easybook_com"
android:textColor="@color/colorBlackText"
android:textSize="20sp" />
<ImageButton
android:id="@+id/actionbar_homebutton"
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/actionbar_drawerbutton"
android:layout_alignParentTop="true"
android:background="?attr/actionBarItemBackground"
android:scaleType="centerInside"
android:src="@drawable/ic_home_black" />
<ImageButton
android:id="@+id/actionbar_drawerbutton"
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="?attr/actionBarItemBackground"
android:scaleType="centerInside"
android:src="@drawable/ic_drawer" />
<ImageView
android:id="@+id/actionbar_reddot"
android:layout_width="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="?attr/actionBarItemBackground"
android:scaleType="centerInside" />
【问题讨论】:
-
检查我的改进答案以满足您的应用要求。
标签: android android-layout textview word-wrap