大佬教程收集整理的这篇文章主要介绍了在Android L中的Cardview中显示UI小部件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的布局代码如下:
<RelativeLayout xmlns:android="http://scheR_654_11845@as.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>
目前显示如下附图:
您可能知道,在FrameLayout中,视图定位之间没有约束或关系.它们将一个显示在彼此之上.如果您想在CardView中使用不同的层次结构,请使用您想要的任何布局.例如:
<android.support.v7.widget.CardView android:id="@+id/card_view" android:BACkground="@color/white" android:layout_width="200dp" android:layout_height="200dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/info_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Textview one" android:gravity="center" android:textSize="36sp" /> <TextView android:id="@+id/info_text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Textview two" android:gravity="center" android:textSize="36sp" /> </LinearLayout> </android.support.v7.widget.CardView>
仅将CardView视为外部装饰,您可以在其中使用任何布局.因此,如果LinearLayout不合适,您可以使用RelativeLayout等.
以上是大佬教程为你收集整理的在Android L中的Cardview中显示UI小部件全部内容,希望文章能够帮你解决在Android L中的Cardview中显示UI小部件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。