dev*_*dev 9 android android-xml floating-action-button
我有一个FloatingActionButton.我希望它是2个LinearLayouts的中间和这样的屏幕中心. 
目前我的设计是这样的
我希望它在屏幕的正中心.怎么做?
这是我的整个xml代码
<android.support.design.widget.CoordinatorLayout
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">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/viewA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.6"
android:orientation="horizontal"/>
<LinearLayout
android:id="@+id/viewB"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="horizontal"/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/ic_plus"
app:layout_anchor="@id/viewA"
android:layout_centerHorizontal="true"
app:layout_anchorGravity="bottom"
android:layout_centerInParent="true" />
Run Code Online (Sandbox Code Playgroud)
Int*_*iya 10
你CoordinatorLayout是一个FrameLayout,所以试试这种方式,我希望它会对你有所帮助.
app:layout_anchorGravity="bottom|center"
Run Code Online (Sandbox Code Playgroud)
以上解决方案对我来说不起作用。我将其更改android:layout_gravity为
android:layout_gravity="bottom|center"
希望能帮助到你 :-)
| 归档时间: |
|
| 查看次数: |
14736 次 |
| 最近记录: |