android-view

Dimensions of usable space in window (action bar and margin excluded)

大憨熊 提交于 2020-01-02 08:56:20
问题 Disclaimer: I rewrote most of this question, including its title, because I partially figured it out. I'd like to maximize the size of the button on all screen sizes, because it looks silly when it is to small. It should look similar to this: (Sadly, I cannot include a picture, because my reputation is too low.) But if I turn the orientation of the device, for example, the button matches it's parents width, becoming ugly proportioned. (Sadly, I cannot include a picture, because my reputation

Separate preferences for each view in an Android app

 ̄綄美尐妖づ 提交于 2020-01-02 05:32:09
问题 I have multiple views that come and go as the application runs. I want each view to have its own personal preferences that are stored as the ID tag of the view. Above these is the "General Preferences" that the sub prefs reference to get their default values when a view it is created. Right now I have it set up that the General Preferences are the default SharedPreferences. But I have no Idea how to create the new preferences and set up an activity UI so the user can change them. Is it pretty

Separate preferences for each view in an Android app

依然范特西╮ 提交于 2020-01-02 05:32:05
问题 I have multiple views that come and go as the application runs. I want each view to have its own personal preferences that are stored as the ID tag of the view. Above these is the "General Preferences" that the sub prefs reference to get their default values when a view it is created. Right now I have it set up that the General Preferences are the default SharedPreferences. But I have no Idea how to create the new preferences and set up an activity UI so the user can change them. Is it pretty

Dim Screen and Block Interaction with BottomSheets

为君一笑 提交于 2020-01-02 02:41:09
问题 BottomSheetBehavior has been introduced in Android Design Support Library 23.2, however it does not dim the rest of the screen and does not block interaction with the rest of the UI. Is there anyway this can be achieved? 回答1: public class BottomSheetDimmedFragment extends BottomSheetDialogFragment { public static final String TAG = BottomSheetDimmedFragment.class.getSimpleName(); @NonNull @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final BottomSheetDialog dialog

How to tell when fragment is not visible in a NavigationDrawer

蹲街弑〆低调 提交于 2020-01-01 19:21:32
问题 I am trying to tell when a user selects a different fragment in my navigation drawer. I was trying to use override fun setUserVisibleHint(isVisibleToUser: Boolean) { super.setUserVisibleHint(isVisibleToUser) } How i switch fragments in my MainActivity: override fun onNavigationItemSelected(item: MenuItem): Boolean { // Handle navigation view item clicks here. when (item.itemId) { R.id.nav_camera -> { // Handle the camera action val fragment: HomeFragment = HomeFragment()

How to tell when fragment is not visible in a NavigationDrawer

♀尐吖头ヾ 提交于 2020-01-01 19:21:14
问题 I am trying to tell when a user selects a different fragment in my navigation drawer. I was trying to use override fun setUserVisibleHint(isVisibleToUser: Boolean) { super.setUserVisibleHint(isVisibleToUser) } How i switch fragments in my MainActivity: override fun onNavigationItemSelected(item: MenuItem): Boolean { // Handle navigation view item clicks here. when (item.itemId) { R.id.nav_camera -> { // Handle the camera action val fragment: HomeFragment = HomeFragment()

How to add a View to an app from another app

最后都变了- 提交于 2020-01-01 15:36:51
问题 My app is called MyNiceApp . MyNiceApp is mostly just a core that loads a view called coreView in the MainActivity onCreate . coreView gets populated by views from other plugins which the user downloads as wishes. I define the various areas on the core view that can be populated by the plugins via Interfaces in MyNiceApp. How can I load and pass Views from plugins into the coreView ? I've been told that RemoteViews are a good option, but I don't know how to implement it. What other options

How to add a View to an app from another app

元气小坏坏 提交于 2020-01-01 15:36:08
问题 My app is called MyNiceApp . MyNiceApp is mostly just a core that loads a view called coreView in the MainActivity onCreate . coreView gets populated by views from other plugins which the user downloads as wishes. I define the various areas on the core view that can be populated by the plugins via Interfaces in MyNiceApp. How can I load and pass Views from plugins into the coreView ? I've been told that RemoteViews are a good option, but I don't know how to implement it. What other options

How to get all children (visible and invisible) from a ListView?

女生的网名这么多〃 提交于 2020-01-01 09:55:58
问题 My problem is similar to ListView getChildAt returning null for visible children, but despite searching I cannot find a solution. I have a ListView with a Scroll. The ListView has 10 items, 7 of which are visible and 3 are hidden by scroll. I also have an external method (out of adapter) that must get all of the children from this ListView (e.g. using getChildAt() ). I need all 10 of the items, but the last 3 are null objects. I've tried code like the following: getListView()

Understanding memory leaks in Android application

心不动则不痛 提交于 2020-01-01 09:44:55
问题 I found the article "Avoiding memory leaks", where it is said that the following code: private static Drawable sBackground; @Override protected void onCreate(Bundle state) { super.onCreate(state); TextView label = new TextView(this); label.setText("Leaks are bad"); if (sBackground == null) { sBackground = getDrawable(R.drawable.large_bitmap); } label.setBackgroundDrawable(sBackground); setContentView(label); } is not a good idea, since: When the screen orientation changes the system will, by