Android-在工具栏中显示文件路径

托马斯·沃斯(Thomas Vos)

我正在寻找一种在工具栏中显示文件路径的方法,如下所示:

如果路径很长,则需要可单击并且应该可滑动。(或小型设备)。

我曾考虑过将aaHorizontalScrollView一起使用,但不知道这是否是实现此目标的最佳方法。有没有更好(更简单)的方法来做到这一点?谢谢!TextViewImageView

编辑:

感谢@aelimill,我发现aRecyclerView可以水平移动,但是我仍然遇到一些问题。如果单击上一个屏幕截图中的文本,则会显示以下内容:

但是对我来说(在将自定义列表项设置为“可点击”之后)是这样的:

(Look at the click animation)

How can I display the circle animation just like other ActionBar items?

Thomas Vos

I solved this by using a RecyclerView as @aelimill suggested. This is the custom list item I used:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    android:id="@+id/relativeLayout">

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/imageButton"
        android:src="@drawable/ic_keyboard_arrow_right_white_24dp"
        android:background="@null"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignTop="@+id/textView"
        android:layout_alignBottom="@+id/textView" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/textView"
        android:background="?android:attr/selectableItemBackgroundBorderless"
        android:clickable="true"
        android:focusable="true"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/imageButton"
        android:layout_toEndOf="@+id/imageButton"
        android:gravity="center"
        android:textSize="16sp"
        android:minWidth="20dp"
        android:textColor="#ffffff"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

Use selectableItemBackground instead of selectableItemBackgroundBorderless to support pre lollipop devices. (It wont be a circle animation, but a rectangle animation).

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章