CardView 中的文本重叠 Android
Text in CardView is overlapping Android
在我的 android 应用程序中,我在 CardView 布局中创建了两个 TextView。第一个 TextView 将显示一个项目的描述,第二个 TextView 将显示该项目的 link。但是每当我 运行 我的应用程序时,第二个文本就会与第一个文本重叠。我想以这样一种方式实现,即在完成第一个文本后,第二个开始。但我没能实现。
这是我的 CardView 布局代码。
<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>
像这样在 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>
您已经在 CardView 中放置了两个 TextView。 CardView的超级class是FrameLayout。将 TextVeiws 放在 LinearLayout 或 Relative Layout 中可以解决您的问题。
<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>
在我的 android 应用程序中,我在 CardView 布局中创建了两个 TextView。第一个 TextView 将显示一个项目的描述,第二个 TextView 将显示该项目的 link。但是每当我 运行 我的应用程序时,第二个文本就会与第一个文本重叠。我想以这样一种方式实现,即在完成第一个文本后,第二个开始。但我没能实现。 这是我的 CardView 布局代码。
<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>
像这样在 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>
您已经在 CardView 中放置了两个 TextView。 CardView的超级class是FrameLayout。将 TextVeiws 放在 LinearLayout 或 Relative Layout 中可以解决您的问题。
<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>