Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在新的CardView中对齐多个TextView_Android_Android Layout_Android Studio - Fatal编程技术网

Android 在新的CardView中对齐多个TextView

Android 在新的CardView中对齐多个TextView,android,android-layout,android-studio,Android,Android Layout,Android Studio,我正在尝试创建一个CardView,它将显示作者的引用,包括作者姓名、引用,然后是引用下面的引用。我想我已经掌握了大部分内容,但是对齐文本视图的一般规则似乎不适用于CardView。我在这里进行了研究,发现您应该将android:layout=“vertical”添加到LinearLayout(或RelativeLayout)中,但这似乎并没有改变我的想法。我还尝试将其添加到CardView本身,认为它继承了直接父级的方向,但也没有运气。我仍然可以看到文本视图彼此重叠,而不是一个接一个 <

我正在尝试创建一个CardView,它将显示作者的引用,包括作者姓名、引用,然后是引用下面的引用。我想我已经掌握了大部分内容,但是对齐文本视图的一般规则似乎不适用于CardView。我在这里进行了研究,发现您应该将
android:layout=“vertical”
添加到LinearLayout(或RelativeLayout)中,但这似乎并没有改变我的想法。我还尝试将其添加到CardView本身,认为它继承了直接父级的方向,但也没有运气。我仍然可以看到文本视图彼此重叠,而不是一个接一个

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    ... >

<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"
    android:layout_gravity="top"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:longClickable="true"
    android:orientation="vertical"
    card_view:cardUseCompatPadding="true"
    card_view:cardCornerRadius="4dp"
    card_view:cardElevation="4dp"
    card_view:contentPadding="10dp"
    >
    <TextView
        android:id="@+id/info_text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textColor="#FF4444"
        android:textSize="24sp"
        android:text="Gordon B. Hinckley"
        />
    <TextView
        android:id="@+id/info_text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/info_text"
        android:text="Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text. Test text."
        />
    <TextView
        android:id="@+id/info_text3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/info_text2"
        android:textColor="#33B5E5"
        android:gravity="end"
        android:text="and I'm the reference."
        />

</android.support.v7.widget.CardView>

... >


有什么想法吗?

解决了。只需将
包装在
中(或任何其他布局),但仍在

中,非常感谢。帮了大忙。我在里面用过,但效果不好。使用作品