use*_*605 1 layout android textview
我想在我的应用程序中创建某种工具栏。在左侧我显示一个固定大小的 imageView,在右侧显示另一个图像视图,在中间我想显示文本,但需要将其截断,以防空间不足......这就是我的位置我失败了
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actionBar"
android:layout_width="match_parent"
android:layout_height="32dp"
android:background="@android:drawable/title_bar"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="left|center_vertical"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/actionBarIcon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginRight="7dp"
android:adjustViewBounds="true"
android:background="@drawable/podcast_addict"
android:gravity="center_vertical"
android:onClick="onHome" >
</ImageButton>
<TextView
android:id="@+id/actionBarTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:singleLine="true"
android:text="@string/app_name"
android:textColor="#FFFFFF"
android:textSize="15sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_weight="2"
android:gravity="right|center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginBottom="3dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="3dp"
android:background="@android:drawable/status_bar_item_app_background" />
<ImageView
android:id="@+id/actionButton"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:adjustViewBounds="true"
android:background="@android:drawable/stat_notify_sync_noanim"
android:gravity="center_vertical"
android:onClick="onAction" >
</ImageView>
<ImageView
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="@android:drawable/status_bar_item_app_background" />
<ImageButton
android:id="@+id/showHideButton"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:adjustViewBounds="true"
android:background="@android:drawable/ic_menu_view"
android:gravity="center_vertical"
android:onClick="onShowHide" >
</ImageButton>
<ImageView
android:layout_width="1px"
android:layout_height="match_parent"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="@android:drawable/status_bar_item_app_background" />
<ImageButton
android:id="@+id/markReadButton"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:adjustViewBounds="true"
android:background="@android:drawable/checkbox_on_background"
android:gravity="center_vertical"
android:onClick="onMarkRead" >
</ImageButton>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当文本很短时,它似乎可以工作,但是当文本太长时,右侧的第一个 imageView 隐藏在文本后面......我该如何解决这个问题?
尝试使用android:ellipsize:
<TextView
android:singleLine="true"
android:ellipsize="end"
android:text="This is a long long text"/>
Run Code Online (Sandbox Code Playgroud)
当文本长于 TextView 宽度时,这将在屏幕上显示This is a long... 。
| 归档时间: |
|
| 查看次数: |
4395 次 |
| 最近记录: |