gpt4 book ai didi

android - 在新的 CardView 中对齐多个 TextView

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:49:26 24 4
gpt4 key购买 nike

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

<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>

有什么想法吗?

最佳答案

解决了。只需要包装 <TextView> s 在 <LinearLayout> (或任何其他布局)但都在 <android.support.v7.widget.CardView> 内.

关于android - 在新的 CardView 中对齐多个 TextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26517913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com