Android FloatActionButton:如何让它伸出View?
Android FloatActionButton: how to make it stick out of a View?
我有一个 FloatActionButton,它必须从包含它的视图中突出一点,但它被切断了。
我怎样才能从容器中取出一点?
示例图片
这是Layout的完整代码,包括CoordinatorLayout和FAB。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_show_image"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/add_text_to_media_image"/>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black_overlay"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/add_text_to_media_detail"
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="wrap_content"
android:layout_gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black_overlay"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:id="@+id/add_text_to_media_text_container">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Aggiungi una descrizione..."
android:textColorHint="@color/material_grey_300"
android:textColor="@color/white"
android:id="@+id/add_text_to_media_text"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_text_to_media_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="normal"
android:src="@drawable/ic_send_white_24dp"
app:layout_anchor="@+id/add_text_to_media_text_container"
app:layout_anchorGravity="right"
android:clickable="true"
android:layout_marginTop="-27dp"
android:layout_marginRight="16dp"
/>
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
使用透明背景使视图更高,如果需要,可以将编辑文本的背景更改为较深的颜色
我有一个 FloatActionButton,它必须从包含它的视图中突出一点,但它被切断了。
我怎样才能从容器中取出一点?
示例图片
这是Layout的完整代码,包括CoordinatorLayout和FAB。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_show_image"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/add_text_to_media_image"/>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black_overlay"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/add_text_to_media_detail"
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="wrap_content"
android:layout_gravity="bottom">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black_overlay"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:id="@+id/add_text_to_media_text_container">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Aggiungi una descrizione..."
android:textColorHint="@color/material_grey_300"
android:textColor="@color/white"
android:id="@+id/add_text_to_media_text"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_text_to_media_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="normal"
android:src="@drawable/ic_send_white_24dp"
app:layout_anchor="@+id/add_text_to_media_text_container"
app:layout_anchorGravity="right"
android:clickable="true"
android:layout_marginTop="-27dp"
android:layout_marginRight="16dp"
/>
</android.support.design.widget.CoordinatorLayout>
</FrameLayout>
使用透明背景使视图更高,如果需要,可以将编辑文本的背景更改为较深的颜色