android-view

How to Measure TextView Height Based on Device Width and Font Size?

拈花ヽ惹草 提交于 2019-12-17 06:09:12
问题 I am looking for method in Android that will take a input (text, text_font_size, device_width) and based on these calculations it will return how much height will required to display particular text ? I am setting a text view/ webview height runtime based on his content,I am aware about warp content but I can't use in my case because of some web view minimum height issue. So I am trying to calculate height and based on that I am setting view height. I have tried with following ways Paint

sendUserActionEvent() is null

旧时模样 提交于 2019-12-17 03:34:16
问题 I've got a real doozy here. When I click on spinners, open menu items, or open context menus on long-clicks I get the same Logcat message: 08-02 21:20:57.264: E/ViewRootImpl(31835): sendUserActionEvent() mView == null The tag is ViewRootImpl , and the message is sendUserActionEvent() mView == null . I could not find anything helpful about this on the web. I searched through the Android sources and found some references to mView , but I could not find the file in which this log message is

Coloring Buttons in Android with Material Design and AppCompat

孤街浪徒 提交于 2019-12-17 02:24:52
问题 Before the AppCompat update came out today I was able to change the color of buttons in Android L but not on older versions. After including the new AppCompat update I am unable to change the color for either version, when I do try the button just disappears. Does anyone know how to change the button color? The following pictures shows what I want to achieve: The white button is default, the red one is what I want. This is what I was doing previously to change the color of the buttons in the

Android AppCompat 21 Elevation

血红的双手。 提交于 2019-12-17 02:21:29
问题 Is there any way to add elevation to a View in pre-lollipop devices without wrapping them in a CardView ? 回答1: ViewCompat.setElevation(View, int) currently creates no shims. The only way to simulate elevation right now is to apply a shadow pre-v21. Define your style/layout/drawable in values and override it in values-v21 . For buttons I use style overrides. For layouts, I usually go for reference override (use @null to get rid of a drawable). Hopefully in the future an update to the support

Android AppCompat 21 Elevation

孤者浪人 提交于 2019-12-17 02:21:26
问题 Is there any way to add elevation to a View in pre-lollipop devices without wrapping them in a CardView ? 回答1: ViewCompat.setElevation(View, int) currently creates no shims. The only way to simulate elevation right now is to apply a shadow pre-v21. Define your style/layout/drawable in values and override it in values-v21 . For buttons I use style overrides. For layouts, I usually go for reference override (use @null to get rid of a drawable). Hopefully in the future an update to the support

android: MultiAutoCompleteTextView style like gmail

痴心易碎 提交于 2019-12-14 01:26:08
问题 I want create custom MultiAutoCompleteTextView like gmail app: I create custom view and extend to MultiAutoCompleteTextView and use Span , but I have problem, if there is not enough room for text and image then and span have (space) then view split them and there is my code for custom view: public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView { @Override public void setTokenizer(Tokenizer t) { super.setTokenizer(t); } public CustomMultiAutoCompleteTextView(Context

Resizing bitmap is cropping instead of scaling in View

我只是一个虾纸丫 提交于 2019-12-13 19:02:57
问题 I can't figure out how to resize a bitmap. Based on posts here Bitmap.createScaledBitmap is the way to do it but it just doesn't work for me. Because of the nature of the view I'm doing everything in onDraw so I don't think I can use a layout or ImageView. Here's what I'm doing: I have an image of the Empire State Building that's 200x200. I run this code to set it up: private void setupBitmap() { int bitmapSize = 100; Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R

Android View.invalidate(Rect) different behavior between two devices

纵饮孤独 提交于 2019-12-13 16:28:15
问题 I have a custom view (a Waveform) that needs to be synchronized with a media player progress. The problem is that I'm having a different behavior when using invalidate(Rect) Here is the code that makes the update in my custom view: public void setProgress(int currentDuration) { // ... Some code to calculate the dirty width invalidate(mDirtyWidth,0,mDirtyWidth+ mDirtyWidthRegion, viewHeight); } This is working perfectly on a Samsung Galaxy 4 (Android 4.4.2). Screenshot with "Show GPU view

Android: set view height via ViewTreeObserver

被刻印的时光 ゝ 提交于 2019-12-13 14:24:18
问题 I have two tables: TableA and TableB. TableA has the first row with height of 22 and TableB has the first row with height of 77. I want to equate first row of TableA to first row of TableB, for that purpose I use code below: void resizeHeaderHeight() { final int[] heightA = new int[1]; final int[] heightB = new int[1]; TableRow TableA_Row = (TableRow) this.tableA.getChildAt(0); TableRow TableB_Row = (TableRow) this.tableB.getChildAt(0); final TextView textViewA = (TextView) TableA_Row

Wrong state class — expecting View State exception in Android 1.5 with Custom View

怎甘沉沦 提交于 2019-12-13 13:06:23
问题 When I switch to landscape mode, the following custom view throws an exception in Android 1.5r3 cupcake: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.opentable/com.opentable.activity.SearchResults}: java.lang.IllegalArgumentException: Wrong state class -- expecting View State My code: public class TextProgressBar extends LinearLayout { public TextProgressBar(Context context, AttributeSet attrs) { super(context, attrs); ((LayoutInflater) context.getSystemService