我想在TextView中显示完整的文本,但是一些textView文本显示在Button后面

时间:2016-04-26 12:47:45

标签: android android-layout listview

此时按钮会隐藏我想要分别显示文字和按钮的文字。并且Marquee不工作。我希望文本视图正确的文本,但在这个时间按钮隐藏TextView的文本 可能是布局中的问题可以帮助我做什么?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >



<ImageView
    android:id="@+id/imageview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" >
</ImageView>
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/btn_booking"
    android:layout_gravity="right"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Medium Text"
    android:id="@+id/text_booking"
    android:layout_gravity="center_horizontal"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:ellipsize="marquee"
    android:layout_alignLeft="@+id/btn_booking"/>


 </RelativeLayout>

2 个答案:

答案 0 :(得分:0)

试试这个 -

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
    android:id="@+id/imageview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" >
</ImageView>
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/btn_booking"

    android:below = "@+id/imageview"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Medium Text"
    android:id="@+id/text_booking"
    android:below = "@+id/imageview"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
  />

 </RelativeLayout>

希望它会有所帮助:)别忘了投票

答案 1 :(得分:0)

试试这个布局

    

<ImageView
    android:id="@+id/imageview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY" >
</ImageView>
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/btn_booking"
    />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Medium Text"
    android:id="@+id/text_booking"
    android:ellipsize="marquee"
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:freezesText="true"
    android:singleLine="true"
   />


 </LinearLayout>

以编程方式设置

textView.setSelected(true)  

需要设置为选框才能工作。

相关问题