我正在尝试在 cardview 中创建一个应用程序,cardview 包含两个文本视图,它们需要彼此相邻放置,但文本视图正在重叠。是否有任何机制可以将元素放置在 Cardviews 的 RelativeLayout(layout_below 或 layout_toRightOf) 中。我可以通过向 Relativelayout 添加阴影并使其看起来像 Cardview 来做到这一点,我想在 Cardview 中执行此操作。
我的布局代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/black"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:background="@color/white"
android:layout_width="200dp"
android:layout_height="200dp">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Textview one"
android:gravity="center"
android:textSize="36sp" />
<TextView
android:id="@+id/info_text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Textview two"
android:gravity="center"
android:textSize="36sp" />
</android.support.v7.widget.CardView>
</RelativeLayout>
目前显示如下图所示: