【发布时间】:2016-07-05 09:56:40
【问题描述】:
如果我的 textview 太长并且开始触摸它,我希望隐藏一个视图,我该怎么做呢?所以例如这样就可以了:
但是当它是一个很长的用户名并且长度接近我想要隐藏时间戳的时间戳时,我该怎么做呢?我这辈子都想不到!
编辑:我目前的布局是这样的
list_item_post.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FFFFFF">
<LinearLayout
android:id="@+id/opBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/authorTextView"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_gravity="start|center"
android:layout_marginStart="10dp"
android:layout_marginTop="15dp"
android:background="@drawable/textview_corner_radius"
android:fontFamily="sans-serif-condensed"
android:paddingBottom="8dp"
android:paddingEnd="18dp"
android:paddingStart="18dp"
android:paddingTop="8dp"
android:textColor="@android:color/white"
android:textStyle="bold"
android:gravity="center" />
<View
android:id="@+id/postTriangle"
android:layout_width="15dp"
android:layout_height="15dp"
android:background="@drawable/ic_purple_triangle"
android:layout_marginStart="12dp"
android:layout_marginTop="-5dp"/>
</LinearLayout>
<TextView
android:id="@+id/dateTime"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:gravity="end"
android:layout_gravity="center"
android:textColor="@color/purple"
android:layout_marginTop="8dp"
android:textSize="12sp"/>
<ImageButton
android:id="@+id/morePostOptions"
android:layout_marginEnd="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_more"
android:layout_gravity="center"
android:layout_marginTop="8dp"/>
</LinearLayout>
<TextView
android:id="@+id/postText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginStart="27dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:textColor="@android:color/black"
android:textSize="14sp"
android:lineSpacingExtra="5dp"/>
<ImageView
android:id="@+id/imagePost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</LinearLayout>
</LinearLayout>
先谢谢了,如果你想看,可以提供任何东西!
【问题讨论】:
-
你目前的布局是什么?
-
@BartekLipinski 添加了
-
也许您可以检查视图边界是否触摸?创建视图
Rects,为其中一个添加所需的空间并检查它们intersect?
标签: android android-linearlayout textview android-view