我希望当用户点击自定义tableview的某一行时,在parrent布局的右上角位置显示两个浮动按钮,但是在布局中显示一半,在布局外显示一半。
以下是示例:
考虑到底部布局在我的表格视图行中,
这是我想添加fab的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainAddEditIcons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:id="@+id/tvLAyout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/tvRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="10dp"
android:paddingLeft="20dp"
android:textColor="@color/black" />
</LinearLayout>
</LinearLayout>
答案 0 :(得分:0)
试试这个
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainAddEditIcons"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/tvLAyout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="@color/colorblueLight"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:padding="10dp"
android:text="NIlu" />
</LinearLayout>
<LinearLayout
android:id="@+id/tvLAyout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorAccent"
android:orientation="vertical" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/l_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:clickable="true"
android:src="@drawable/floating_add"
app:backgroundTint="@color/colorOrange"
app:fabSize="normal"
app:layout_anchor="@id/tvLAyout1"
app:layout_anchorGravity="bottom|right" />
</android.support.design.widget.CoordinatorLayout>
<强>输出强>
试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/nilu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:orientation="vertical"
android:paddingBottom="30dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
</LinearLayout>
<LinearLayout
android:id="@+id/nilu2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/nilu"
android:background="@color/colorGray"
android:orientation="vertical"
android:paddingTop="30dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="NILU" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/nilu"
android:layout_marginTop="-15dp"
android:orientation="horizontal">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="16dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:src="@mipmap/ic_launcher_round"
app:elevation="2dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<强>输出强>
答案 1 :(得分:0)
您可以尝试以下代码:
{{1}}