android-ui

How to selectively decorate RecyclerView items

心不动则不痛 提交于 2019-12-17 17:39:23
问题 I am creating a subclass of ItemDecoration from this gist: https://gist.github.com/alexfu/0f464fc3742f134ccd1e How to make it only decorate items with certain condition? For instance, only decorate items with certain positions, type of ViewHolder, etc. I have modified the above mentioned gist (plus some changes on deprecated Android API) with this code, but all items get decorated anyway: public boolean isDecorated(View view, RecyclerView parent) { RecyclerView.ViewHolder holder = parent

Build Play Music-like interface

为君一笑 提交于 2019-12-17 17:34:00
问题 I'm trying to build and interface that would mimic the recent Google Play Music interface which as a reminder looks like this on a phone I've already got the DrawerLayout and the Tabs right, but I have no idea how to build the amazing bottom fragment that displays the currently playing song. It mixes two features: If you swipe this fragment to the left, it will be replaced by the next song. i think it can be done fairly quickly using a ViewPager and a new Fragment for each song, but is it an

How to align LinearLayout at the center of its parent?

吃可爱长大的小学妹 提交于 2019-12-17 15:22:05
问题 I've looked through numerous similar questions here at SO, but nothing helps. I have a hierarchy of different nested layouts, all have android:layout_width="fill_parent" , and the inner-most layout has android:layout_width="wrap_content - I need to align it at the center (horizontally). How do I do that? Update: : I've found the cause of the problem - if I put the inner LinearLayout into RelativeLayout with android:layout_width="fill_parent" , it still wraps it's content. The TableRow,

Getting DrawerLayout to Slide over the ActionBar

无人久伴 提交于 2019-12-17 10:18:05
问题 I have a sliding drawer menu in an activity, which has an actionbar with some tabs on it. I'd like to get the sliding drawer to slide over the tabs , not below them. This is what it looks like right now... Any ideas on how this could be done? Note: I understand that I might be breaking some conventions and UI patterns here, and if it does not work at all, I'll look at alternatives. But I'd like to get this working first. EDIT: See the below screen shot of the Google Play Music app that does

How to display both icon and title of action inside ActionBar?

寵の児 提交于 2019-12-17 07:04:41
问题 I need to display both icon and title of action inside ActionBar . I've tried " withText " option, but it has no effect. 回答1: ' always|withText ' will work if there is sufficient room, otherwise it will only place icon. You can test it on your phone with rotation. <item android:id="@id/menu_item" android:title="text" android:icon="@drawable/drawable_resource_name" android:showAsAction="always|withText" /> 回答2: You can create actions with text in 2 ways: 1- From XML: <item android:id="@id

How to use asynctask to display a progress bar that counts down?

自作多情 提交于 2019-12-17 06:45:41
问题 In my application i want the user to press a button and then wait 5 mins. i know this sounds terrible but just go with it. The time remaining in the 5 min wait period should be displayed in the progress bar. I was using a CountDownTimer with a text view to countdown but my boss wants something that looks better. hence the reasoning for a progress bar. 回答1: You can do something like this.. public static final int DIALOG_DOWNLOAD_PROGRESS = 0; private ProgressDialog mProgressDialog; @Override

How to take a screenshot of other app programmatically without root permission, like Screenshot UX Trial?

六月ゝ 毕业季﹏ 提交于 2019-12-17 05:32:31
问题 How to take a screenshot of other app programmatically without root permission, like Screenshot UX Trial? I know I can capture the bitmap of the root view in my app. But I can't get the root view of the other app when my app is running in background bitmap = Bitmap.createBitmap(rootview.getDrawingCache()); There is a permission for capturing current frame buffer in Manifest: android.permission.READ_FRAME_BUFFER . But some website says it's for signature app only. Check Android Permissions -

Strange issue with android:ellipsize=“end”

筅森魡賤 提交于 2019-12-14 03:41:16
问题 I am using android:ellipsize="end" in android xml file, & surprisingly I am not getting the layout that I want, the 3 dots(...) are showing but after that dots there is another word truncated. Also this is a "not-always" behavior, check the ListView attached, sometimes, the behavior is normal & sometimes not. Here's the screenshot of the layout from my device, I don't have any idea why this is happening. Here's my xml file, having problem with the tv_news_content TextView - <?xml version="1.0

Update UI through Handler

我的未来我决定 提交于 2019-12-14 03:12:20
问题 I need to update my UI from an external Thread . I can't use runOnUiThread, because it's an application using StandOut libraries. So I created my Handler in the class containing methods to update the UI: private final class UIHandler extends Handler { public static final int DISPLAY_UI_TOAST = 0; private static final int LOAD_PROFILE = 1; public UIHandler(Looper looper) { super(looper); } @Override public void handleMessage(Message msg) { switch (msg.what) { case UIHandler.DISPLAY_UI_TOAST: {

Custom dialog hasn't divider under the title

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-14 02:41:14
问题 At the official documentation there is an article of how to create custom dialogs. And there is also a picture of result dialog which have gradient border under it's title. When I copy this code to run it on my machine and look at the results I get the dialog without gradient divider between the dialog's title and it's content: Is this normal behavior and if it is, tell me how can I add divider by myself through the code, or using styles mechanism? 回答1: Yes this is a normal behavior for