【问题标题】:I want to set the fab button so that it changes position to adapt to screen size我想设置 fab 按钮,以便它改变位置以适应屏幕尺寸
【发布时间】:2017-06-02 17:29:33
【问题描述】:

我的 XML fab 布局。正如标题所说,我已经为此苦苦挣扎了一段时间,在网上找不到任何解决方法

 <android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="285dp"
    android:layout_marginTop="430dp"

    android:clickable="true"
    android:elevation="200dp"
    app:backgroundTint="@android:color/holo_red_dark"
    app:elevation="17dp"
    app:fabSize="normal"
    app:rippleColor="@android:color/holo_red_light"
    app:srcCompat="@drawable/ic_action_new" />

【问题讨论】:

  • 你能说得更清楚些吗?

标签: android xml android-studio floating-action-button


【解决方案1】:

将此作为父级

<?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:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

</android.support.design.widget.CoordinatorLayout>

在清单中使用这个:

android:windowSoftInputMode="adjustResize"

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2012-02-10
    • 2020-01-23
    • 1970-01-01
    • 2022-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    相关资源
    最近更新 更多