gpt4 book ai didi

java - 如何在选项卡布局中的 RelativeLayout 上显示 Fab

转载 作者:行者123 更新时间:2023-11-29 19:02:43 24 4
gpt4 key购买 nike

我有一个选项卡布局,在其中一个选项卡上显示相对布局,我希望这个特定选项卡在底部显示一个晶圆厂。当我将晶圆厂添加到它显示的布局设计 View 时,但当我在设备上测试时,晶圆厂“消失”- 根本不显示”

这是我的标签项相对布局。

<?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:id="@+id/compose_query_content_linear_layout"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<EditText
android:id="@+id/query_subject_editText"
android:hint="@string/query_subject_text"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white"
android:padding="16dp"
android:ems="10"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/query_content_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/query_subject_editText"
android:ems="10"
android:hint="@string/compose_query_content_text"
android:padding="16dp"
android:textColor="@android:color/white"
android:textColorHint="@android:color/white" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/query_floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_gravity="end|bottom"
android:layout_marginBottom="91dp"
android:layout_marginEnd="58dp"
android:src="@drawable/ic_action_notifications_busket"
android:tint="@android:color/white"
app:borderWidth="4dp"
app:fabSize="normal"
app:rippleColor="@color/muzima_theme_blue" />


</RelativeLayout>

这是我的标签父布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/message_basket_main_activity_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
android:id="@+id/message_basket_main_activity_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimaryDark"
android:title="@string/app_name"
app:theme="@style/ToolbarTheme" />

<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/message_basket_tab_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
android:background="@color/colorPrimaryDark"
app:tabGravity="center"
app:tabMaxWidth="0dp"
app:tabMode="scrollable"
app:tabSelectedTextColor="@color/muzima_theme_blue"
app:tabTextColor="@android:color/white"
tools:context="phr.muzima.org.phr.MessageBasketMainActivity">

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


<android.support.v4.view.ViewPager
android:id="@+id/message_basket_view_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>

这里是我的 fragment activity.java

package phr.muzima.org.phr.fragments;

import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;

import java.util.Arrays;
import java.util.List;

import phr.muzima.org.phr.R;
import phr.muzima.org.phr.adapters.UpdatesAdapter;
import phr.muzima.org.phr.model.Update;

/**
* Created by HP on 1/19/2018.
*/

public class PatientQueriesFragment extends Fragment {

FloatingActionButton fab;

public PatientQueriesFragment() {

}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.patient_queries_fragment_layout,
container, false);
fab = view.findViewById(R.id.query_floatingActionButton);

return view;
}
}

最佳答案

我自己也遇到过类似的问题,发现使用协调器布局对 FAB 效果很好。将 FAB 放在这个布局上,然后像往常一样放置相对布局。

关于java - 如何在选项卡布局中的 RelativeLayout 上显示 Fab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48353979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com