Я пытаюсь создать CardView, который будет отображать цитату автора, включая имя автора, цитату, а затем ссылку под ней. Я думаю, что у меня есть большая часть этого, но кажется, что общие правила для выравнивания TextViews, кажется, не применяются к CardView. Я исследовал здесь и обнаружил, что вы должны добавить android:layout="vertical"
в LinearLayout (или RelativeLayout), но, похоже, это ничего не меняет для меня. Я также попытался добавить его в сам CardView, думая, что он наследует ориентацию от непосредственного родителя, но тоже не повезло. Я все еще получаю TextViews, перекрывающие друг друга, а не один за другим.
<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>
Есть мысли?