Android CardView中的文本重叠
在我的android应用程序中,我在CardView布局中创建了两个TextView。第一个文本视图将显示一个项目的描述,第二个文本视图将显示该项目的链接。但每当我运行我的应用程序时,第二个文本就会与第一个文本重叠。我想以这样一种方式实现,在完成第一个文本后,第二个文本以start开头。但我没有实现这一点。 这是我的CardView布局代码Android CardView中的文本重叠,android,android-linearlayout,textview,android-relativelayout,android-cardview,Android,Android Linearlayout,Textview,Android Relativelayout,Android Cardview,在我的android应用程序中,我在CardView布局中创建了两个TextView。第一个文本视图将显示一个项目的描述,第二个文本视图将显示该项目的链接。但每当我运行我的应用程序时,第二个文本就会与第一个文本重叠。我想以这样一种方式实现,在完成第一个文本后,第二个文本以start开头。但我没有实现这一点。 这是我的CardView布局代码 <RelativeLayout android:layout_width="match_parent" android
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text"/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/link"
android:layout_gravity="bottom"
android:textAppearance="?android:attr/textAppearanceSmall" />
</android.support.v7.widget.CardView>
</RelativeLayout>
让你的布局像这样
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text" />
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="@string/link"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
让你的布局像这样
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text" />
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="@string/link"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
在
卡片视图中使用相对视图
或线性布局
,如下所示:
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dklfjkdsjfsd"
/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/news_description"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</android.support.v7.widget.CardView>
希望这能帮助您解决问题。…在CardView
中使用RelativeLayout
或LinearLayout
,如下所示:
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dklfjkdsjfsd"
/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/news_description"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text"/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/link"
android:layout_gravity="bottom"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
希望这能帮到你……
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text"/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/link"
android:layout_gravity="bottom"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
您在CardView中放置了两个文本视图。CardView的超类是FrameLayout。将文本放在线性布局或相对布局中可以解决您的问题
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text"/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/link"
android:layout_gravity="bottom"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</android.support.v7.widget.CardView>
您在CardView中放置了两个文本视图。CardView的超类是FrameLayout。将文本放在线性布局或相对布局中可以解决您的问题
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/news_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/large_text"/>
<TextView
android:id="@+id/webLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/link"
android:layout_gravity="bottom"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</android.support.v7.widget.CardView>
在cardview内部采用线性布局。。。在线性布局中添加文本视图您必须在CardView中使用布局(相对或线性)。@pcg我可以保留相对布局吗。你能给我一张卡德维尤内部线性布局的照片吗。。。在线性布局中添加文本视图您必须在CardView中使用布局(相对或线性)。@pcg我可以保留相对布局吗。你能给我一个枫树吗