android-view

Insert views in HorizontalScrollView programmatically

别来无恙 提交于 2019-12-25 02:41:15
问题 I'm making a chat app which looks like this(dummy view): Use the xmls & activity exactly as they are <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <HorizontalScrollView android:id="@+id/chat_message_HSV" android:layout_width="fill_parent" android:layout_height="75dp" android:layout_alignParentBottom="true" android:layout_toLeftOf="@+id/send" android

Align XML drawable background to bottom of view

亡梦爱人 提交于 2019-12-25 01:34:53
问题 I am trying to provide a simple solid-color underline to a TextView header. I want this to be reusable and to work with any view in the future, regardless of height. I am trying to favor a background drawable so I can simply apply it to view. I can draw a line without any problem: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:shape="line" > <stroke android:color="#8a9299" android:width="1dp" /> </shape> This line is, however,

Catch onTouch event by Custom 2d Scrollview parent, handle it and pass to children

你。 提交于 2019-12-25 00:09:07
问题 I'm trying to implement Catch onTouch event by parent, handle it and pass to children butt failed to do that. Gist of full 2d scroll code is here what I have tried: Override the method dispatchTouchEvent , and sent the MotionEvent to a GestureDetector @Override public boolean dispatchTouchEvent (MotionEvent ev) { // return super.dispatchTouchEvent(ev); boolean result = super.dispatchTouchEvent(ev); if (gestureDetector.onTouchEvent(ev)) { return result; } //If not scrolling vertically (more y

dynamically adding views and toasting it

荒凉一梦 提交于 2019-12-24 19:08:06
问题 I'm adding views dynamically. Mean to say that, Initially there is one EditText , Button Add , Button Submit . 1.OnClick of Button Add I'm inflating new layout which has one EditText and Button Remove . If Button Add is keep on pressed it will add inflated layout respectively. 2.OnClick of Button Submit it has to Toast the EditText values of Inflated layout. I'm getting only the last EditText Toast, and the Toast for rest of EditText didn't show. how to do this? public class MainActivity

How to remove inner bottom space (bottom margin/padding) of text/layout inside a SearchView?

你离开我真会死。 提交于 2019-12-24 13:52:40
问题 So I got this SearchView that has a default space at the bottom for the text inside it. How can I reduce it (see the red lines in picture): 回答1: Imagine you have SearchView named: searchBar SearchView searchBar = (SearchView) findViewById(R.id.searchViewBar); Get the view ( AutoCompleteTextView ) that holds the text inside your SearchView : //The view that contains the SearchView text AutoCompleteTextView searchTextContent = (AutoCompleteTextView) searchBar.findViewById(searchBar.getContext()

Custom view Canvas onDraw() doesnt draw anything

喜夏-厌秋 提交于 2019-12-24 12:31:23
问题 I am trying to draw a oval using canvas, but it never gets drawn. Here is my code for the custom view. I have also used setWillNotDraw(false) still nothing gets drawn on the screen. public class Myview extends View { Paint paint; RectF rect; public Myview(Context context) { super(context); init(); setWillNotDraw(false); } public Myview(Context context, AttributeSet attrs) { super(context, attrs); init(); setWillNotDraw(false); } public Myview(Context context, AttributeSet attrs, int defStyle)

WebView : WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING : Below Android 4.4?

为君一笑 提交于 2019-12-24 04:53:13
问题 Is there backward compatibility for WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING property of webview's settings (Introduced in API level 19)? (http://developer.android.com/reference/android/webkit/WebSettings.LayoutAlgorithm.html) I tried this (https://github.com/pwnall/chromeview/tree/master/src/org/chromium/android_webview) but not useful. I need WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING above 4.0 API level. 回答1: No, TEXT_AUTOSIZING was added in the KitKat WebView and would be rather hard

How to reset or unset a view height or width which were set programmatically

倾然丶 夕夏残阳落幕 提交于 2019-12-24 01:27:16
问题 I am struggling with this and I cannot find a direct answer to this question due to its generic keywords leading the results to unrelated questions. If I set a view's height or width programmatically, for example: ((Button) findViewById(R.id.myButtonId)).getLayoutParams().height = 100; How can I unset/reset/revert this process so the view's height (or width) returns to its default behavior before that size was set? I am trying to find something like the Html CSS equivalent of height: unset or

ViewGroup throwing NullPointerException in dispatchDragEvent

≡放荡痞女 提交于 2019-12-24 00:47:31
问题 I am in the process of coding a drag and drop library for GridViews. I am almost complete...however, I am getting an annoying NullPointerException upon ACTION_DROP every now and then. It points to the ViewGroup source code, lines 1147 and 1153, saying it is getting a null pointer when trying to recycle the drag event. Some background on my process: I am basically embedding an OnDragListener into a custom adapter for a GridView. I have the user (programmer) implement an OnGetViewListener, when

Android getDrawable() Deprecated / How To use Android getDrawable()

南笙酒味 提交于 2019-12-23 22:16:04
问题 Can anyone tell me the right way of using getDrawable() , I recall last time I used it was just fine with one parameter, but now I am getting this method is deprecated error, anyone? Bellow is the snippet I am trying to use private void toggleUi() { ImageView imageView = (ImageView) findViewById(R.id.silent_icon); Drawable silentImage; if(silent) { silentImage = getResources().getDrawable(R.drawable.silent_on); } else { silentImage = getResources().getDrawable(R.drawable.silent_off); }