android-layout

StaggeredGridLayoutManager: Adding Margin makes the layout items pushed to the side

眉间皱痕 提交于 2020-08-20 11:46:05
问题 So, I'm working on a small project and I wanted to add StaggeredGridLayoutManager to the file. While it works if I don't add an itemDecorator and no margin or padding in my layouts. As soon as I add margins it pushes the list to one side. I'm attaching a screenshot to clarify the issue. Here is my Code: recyclerView.setHasFixedSize(true); StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); recyclerView.addItemDecoration(new

Immersive fullscreen on Android 11

这一生的挚爱 提交于 2020-08-10 23:38:32
问题 Before, to enable immersive fullscreen mode, you'd have to use setSystemUiVisibility , like so: getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); As of API 30, it's deprecated, so what's the workaround? 回答1: As documentation suggests, you should use

Immersive fullscreen on Android 11

╄→гoц情女王★ 提交于 2020-08-10 23:36:08
问题 Before, to enable immersive fullscreen mode, you'd have to use setSystemUiVisibility , like so: getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); As of API 30, it's deprecated, so what's the workaround? 回答1: As documentation suggests, you should use

RecycleView TouchListener while autoScroll

亡梦爱人 提交于 2020-08-09 21:24:06
问题 I try to make RecyclerView with AutoScroll function. Now it working fine. But I want to TouchEvent with AutoScroll. It means if user didn't touch, list is auto scrolled. And if user touch, list move to follow user's finger. But now if user touch list, list stoped, but after 1 second it move again even still finger is touched. Here is my code. recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener() { @Override public boolean onInterceptTouchEvent(RecyclerView rv,

displaying my toolbar image as background to status bar effecting navigation bar in android

你说的曾经没有我的故事 提交于 2020-08-08 05:37:21
问题 I want my toolbar to take the space of status bar and the image used for it be the background of the status bar and I successfully do that with this code inside my activity // for using status bar space if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } the problem is this code make my activity layout take the full screen even the space with navigation bar so how

displaying my toolbar image as background to status bar effecting navigation bar in android

為{幸葍}努か 提交于 2020-08-08 05:37:07
问题 I want my toolbar to take the space of status bar and the image used for it be the background of the status bar and I successfully do that with this code inside my activity // for using status bar space if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } the problem is this code make my activity layout take the full screen even the space with navigation bar so how

How to set images on the same row as two TextViews?

筅森魡賤 提交于 2020-08-08 05:25:08
问题 I'm trying to create the following layout: Basically, I have two TextViews and two icons. The icons are on the same row as the mobile header and the the mobile number. I have created the following XML: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/phone_header" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/primaryDarkColor" android:textStyle="bold" android:text="Phone

Why is my DialogFragment not showing the custom layout?

徘徊边缘 提交于 2020-08-06 14:00:51
问题 I want to show a DialogFragment with no title, buttons, etc.(i.e, none of what is included in a typical Dialog) but just a ProgressBar spinner on a plain background. For a rough idea, the background's width matches that of the parent and spinner lies at the center of it. For this, I have a custom layout as follows: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com

Android mirror vector drawable

╄→гoц情女王★ 提交于 2020-08-06 11:41:28
问题 I use a material icon (ic_play_arrow_black_24dp), imported it with the vector studio. Now I want the arrow to point in the other direction as well, without creating a second vector. Is this possible in xml and how? I use the drawable in two Floating Action Button, one for next the other for previous. Edit here is the fab button's XML. I tried already rotation and scale, but it didn´t work <android.support.design.widget.FloatingActionButton android:id="@+id/previous" android:layout_width="wrap

Android mirror vector drawable

安稳与你 提交于 2020-08-06 11:39:29
问题 I use a material icon (ic_play_arrow_black_24dp), imported it with the vector studio. Now I want the arrow to point in the other direction as well, without creating a second vector. Is this possible in xml and how? I use the drawable in two Floating Action Button, one for next the other for previous. Edit here is the fab button's XML. I tried already rotation and scale, but it didn´t work <android.support.design.widget.FloatingActionButton android:id="@+id/previous" android:layout_width="wrap