android-layout

How does Facebook Messenger draw a chathead? (Android)

非 Y 不嫁゛ 提交于 2020-01-10 04:07:05
问题 I know this has already been asked a lot of times here on StackOverflow, but I'm fascinated how Facebook Messenger draws the Chatheads. I followed this tutorial to place an ImageView as an overlay. However, dragging it around is very sluggish, unlike Chatheads which show extremely smooth animation. Turning on the "Show GPU view updates" option in Developer options flashes the screen while a Chathead is being dragged. However, dragging my ImageView doesn't trigger any flashing. Here's a small

Finding the View location (position) on display (screen) in android

♀尐吖头ヾ 提交于 2020-01-10 03:50:12
问题 I want to find the view's position on the display screen. To do it, I use the methods such as view.getLeft() , view.getBottom() , view.getRight() , view.getTop() . But unfortunately, all these methods are returned 0 . Is there any alternate way to find the view's positions (i.e coordinates on screen)? My layout main.xml : <TextView android:id="@+id/tv1" android:layout_width="200px" android:layout_height="30px" android:text="welcome to" /> <TextView android:id="@+id/tv2" android:layout_width=

Android set edit text style globally in theme doesn't work

僤鯓⒐⒋嵵緔 提交于 2020-01-10 00:38:30
问题 I am facing with problem. I am trying to make edit texts in my app look the same with the help of theme. I have generated styles with the help of online tools (9-patch images) and tried to set it in my theme like this <!-- Base application theme. --> <style name="DefaultAppTheme" parent="Theme.AppCompat"> <!-- Main theme colors --> <!-- your app branding color for the app bar --> <item name="colorPrimary">@color/blue</item> <!-- darker variant for the status bar and contextual app bars -->

How to Add icons adjacent to titles for Android Navigation Drawer

一个人想着一个人 提交于 2020-01-09 13:01:48
问题 I am currently working on an android app for 4.2.2 that uses the new NavigationDrawer. It works like a charm except for adding icons. I found some sample code in which the List view becomes a Relative layout in which 2 parallel arrays are nested and rendered by an Array Adapter based on a menu model a way that they are synchronized, I think. Here is the MainActivity: package com.sorin.medisynced.main; import android.app.Activity; import android.app.SearchManager; import android.content.Intent

android 5 and onClick in xml layout

走远了吗. 提交于 2020-01-09 11:07:32
问题 i have set android:onclick in xml for an imageButton and put that method in my activity. in android s below 5 it works fine but in android 5 it give me Error. my imageButton code: <ImageButton android:id="@+id/photo_detail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/detail_icon" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:background="@drawable/image_background" android:onClick="photoDetailButtonMethod"

background scrolling with item in gridview

家住魔仙堡 提交于 2020-01-09 10:33:12
问题 How do I implement background scrolling with a gridview? If it sounds vague, I mean like implementing a bookshelf using a gridview where the shelf image is attached to an item in the gridview. 回答1: It took me forever to figure this out, so for everybody trying to do this, here's the code from my e-book reader. It's based on Shelves by Romain Guy so he deserves the credit for the original code. package net.nightwhistler.pageturner.view; import net.nightwhistler.pageturner.R; import net

background scrolling with item in gridview

瘦欲@ 提交于 2020-01-09 10:33:05
问题 How do I implement background scrolling with a gridview? If it sounds vague, I mean like implementing a bookshelf using a gridview where the shelf image is attached to an item in the gridview. 回答1: It took me forever to figure this out, so for everybody trying to do this, here's the code from my e-book reader. It's based on Shelves by Romain Guy so he deserves the credit for the original code. package net.nightwhistler.pageturner.view; import net.nightwhistler.pageturner.R; import net

collapsing toolbar layout like google play store

社会主义新天地 提交于 2020-01-09 09:12:11
问题 i want to make a collapsing toolbar layout like google play store. like this: https://sendvid.com/ugjspx8r and here is my layout: http://sendvid.com/s4mx3xem how can i do that with new android support library? here is my layout xml file: <android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android

SwipeRefreshLayout - swipe down to refresh but not move the view pull down

喜你入骨 提交于 2020-01-09 09:07:23
问题 Is it possible ?? as a Title said swipe down to refresh Layout but stick the Layout not move it down along swipe gusture Thank you - I'm using SwipeRefreshLayout 回答1: You try this way listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { boolean enable = false; if(listView != null && listView

How to get line count of textview before rendering?

[亡魂溺海] 提交于 2020-01-09 09:06:07
问题 How can I get the number of lines a string will take up in a TextView before it is rendered. A ViewTreeObserver will not work because those are only fired after it is rendered. 回答1: final Rect bounds = new Rect(); final Paint paint = new Paint(); paint.setTextSize(currentTextSize); paint.getTextBounds(testString, 0, testString.length(), bounds); Now divide the width of text with the width of your TextView to get the total number of lines. final int numLines = (int) Math.ceil((float) bounds