android 布局 浮动按钮,android – 如何仅在Tab布局中将浮动操作按钮专门放在一个片段上...

这是我为类似问题所做的.我宣布了片段的协调器布局.在图像中我可以看到的协调器布局内部我已经声明了一个我使用的循环器视图,下面我声明了我的浮动动作按钮.

在此之后,我在onCreateView片段方法中夸大了浮动操作按钮的布局.

这是我的XML文件代码:

android:id="@+id/main_content"

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:focusableInTouchMode="true">

android:id="@+id/search_string"

android:layout_width="match_parent"

android:layout_height="40dp"

android:layout_margin="5dp"

android:layout_marginTop="50dp"

android:hint="Search Keyword"

android:drawableLeft="@drawable/search"

android:gravity="left" >

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/photo_recycler_view"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_marginTop="50dp"

android:scrollbars="vertical"/>

android:id="@+id/fab"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="bottom|end"

android:layout_margin="@dimen/fab_margin"

android:src="@drawable/ic_action_name6" />

这是我的Java文件代码:

@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_photo_list, container, false);

FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);

fab.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

Photo photo = new Photo();

PhotoLab.get(getActivity()).addPhoto(photo);

Intent intent = PhotoPagerActivity.newIntent(getActivity(), photo.getId());

startActivity(intent);

/*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)

.setAction("Action", null).show();*/

}

});

mSearchString=(EditText) view.findViewById(R.id.search_string);

mPhotoRecyclerView = (RecyclerView) view.findViewById(R.id.photo_recycler_view);

mPhotoRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));

updateUI();

return view;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值