【问题标题】:Two textviews on listview aligend rightlistview 上的两个 textviews 对齐
【发布时间】:2014-10-27 18:53:41
【问题描述】:

我想要我的列表视图上的 2 个文本视图,我想要其中一个具有右对齐和另一个对齐中心,但它们都向左对齐!我的列表视图 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="match_parent"
  android:background="#ffffff"
  android:orientation="vertical">

  <TextView 
    android:layout_gravity="center"
    android:gravity="center"
    android:id="@+id/tv_subject"
    android:layout_weight="0.5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"     
    android:textSize="13sp"   
    android:textStyle="bold" />

  <LinearLayout 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal">    

  <ImageView 
    android:id="@+id/iv_pic"
    android:layout_gravity="left"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:contentDescription="ads"/>

   <TextView 
    android:layout_gravity="right"
    android:gravity="right"
    android:textColor="#ffffff"
    android:paddingRight="5dp"
    android:layout_weight="0.5"
    android:id="@+id/tv_details"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
    </LinearLayout>
  </LinearLayout>

此代码成功运行,但是当编译器构建应用程序并且我想在列表视图中触摸一行时,实际上当我的手指位于列表视图时,行的颜色应该改变,但是因为我必须设置宽度 match_parent 它覆盖整个屏幕。 我怎样才能使它成为我想要的输出,当我的手指在选定的行上时,用户会看到该行的颜色发生了变化。

【问题讨论】:

  • 你的问题不是很清楚。你能再解释一下正在发生的事情和预期的事情吗?

标签: android


【解决方案1】:

只需删除android:background="#ffffff"。如果你想改变颜色 - 将它设置为 ListView。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-15
    • 2017-06-08
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    • 1970-01-01
    • 2013-12-14
    相关资源
    最近更新 更多