Android界面开发:如何只显示一个“+”按钮
如果你只想在界面上出现一个' + '按钮,而不是每一行都有一个,你可以将' + '按钮的代码移动到RelativeLayout的外部。以下是修改后的代码:/n/nxml/n<?xml version='1.0' encoding='utf-8'?>/n<RelativeLayout xmlns:android='http://schemas.android.com/apk/res/android'/n android:layout_width='match_parent'/n android:layout_height='wrap_content' >/n/n <RelativeLayout/n android:id='@+id/rl_title'/n android:layout_width='match_parent'/n android:layout_height='wrap_content'/n android:paddingTop='10dp' >/n/n <ImageView/n android:layout_width='wrap_content'/n android:layout_height='wrap_content'/n android:layout_centerVertical='true'/n android:layout_marginLeft='8dp'/n android:background='@drawable/img_line_point' />/n/n <TextView/n android:id='@+id/txt_date_time'/n android:layout_width='wrap_content'/n android:layout_height='wrap_content'/n android:layout_centerVertical='true'/n android:layout_marginLeft='38dp'/n android:textColor='#FC6802' />/n </RelativeLayout>/n/n <TextView/n android:id='@+id/txt_date_content'/n android:layout_width='wrap_content'/n android:layout_height='wrap_content'/n android:layout_below='@id/rl_title'/n android:layout_marginLeft='30dp'/n android:paddingBottom='10dp'/n android:textColor='#5296C5' />/n/n <View/n android:id='@+id/v_line'/n android:layout_width='3dp'/n android:layout_height='wrap_content'/n android:layout_marginLeft='20dp'/n android:background='#FC6802' />/n/n</RelativeLayout>/n/n<ImageView/n android:id='@+id/btn_add'/n android:layout_width='wrap_content'/n android:layout_height='wrap_content'/n android:layout_alignParentRight='true'/n android:layout_alignParentTop='true'/n android:layout_marginRight='8dp'/n android:layout_marginTop='8dp'/n android:src='@drawable/ic_add' />/n/n/n在这个修改后的代码中,我们将' + '按钮的代码移动到RelativeLayout的外部,这样它就不会在每一行都出现了。请注意,这段代码中的ImageView应该放在RelativeLayout的外部,以确保它不会与其他元素发生重叠。
原文地址: https://www.cveoy.top/t/topic/TsP 著作权归作者所有。请勿转载和采集!