android-custom-view

give space between text and underline with customview android

与世无争的帅哥 提交于 2019-12-10 23:26:19
问题 I want an underline below OPTING like below, but when i create this will the help of customview, underline appears just below opting but i want some space between text and line like image I had created a Custom view, in which a word will searched in a string if that is found, then that corresponding text will be underlined but the only thing i want is to give some space between underline and text, My class is as follows, import android.content.Context; import android.content.res.TypedArray;

RTL support to custom editext for drawable left

限于喜欢 提交于 2019-12-10 21:42:25
问题 I have an edittext having an image as drawable left with a non-editable prefixed editext but now i wanted to make it to support rtl. Despite my effort I am not able to support rtl. My Custom class is as follows, public class PrefixedEditText extends TextInputEditText { private String mPrefix = "+"; // can be hardcoded for demo purposes private Rect mPrefixRect = new Rect(); // actual prefix size public PrefixedEditText(Context context, AttributeSet attrs) { super(context, attrs); } @Override

Define default values for layout_width and layout_height properties for a subclass in a style

梦想与她 提交于 2019-12-10 20:56:33
问题 Min and target SDK are 21 (Lollipop), no support library is used. I am trying to create a floating action button. So far so good, it does indeed work (based on a few other SO threads), here is the code: attrs.xml: <?xml version="1.0" encoding="utf-8"?> <resources> <attr name="fabStyle" format="reference"/> </resources> styles.xml <?xml version="1.0" encoding="utf-8"?> <resources> <style name="MyTheme" parent="android:Theme.Material.Light.NoActionBar"> <item name="floatingActionButtonStyle">

Passing values to custom view in android

点点圈 提交于 2019-12-10 15:30:40
问题 Cheers, I have an app that receives user input (2 numbers, width and height) and in theory depending on that input I have a custom view that should draw a grid (width and height). Note: These 2 values should be received before view attempts to draw itself. These 2 values aren't constant and therefore I don't think XML approach can help. I was told that adding another parameter to the View constructor is evil. Do not confuse my 2 values with canvas.getWidth or etc.. these are values needed

How to get attributes with namespace “android” in custom TextView

旧街凉风 提交于 2019-12-10 14:55:37
问题 In custom TextView I'm trying to obtain value of a text attribute (for example). TypedArray values = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.TextView); String text = values.getString(com.android.internal.R.styleable.TextView_text); But I'm getting this error message: package com.android.internal.R does not exist So how to retrieve "default" attributes of TextView? 回答1: The internal.R class isn't visible so you can only read them through their accessor methods

How to show number keyboard on custom view

烈酒焚心 提交于 2019-12-10 13:57:46
问题 I created a custom view: public class MyCustomView extends LinearLayout {...} When user touch it, I show keyboard like this: @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { requestFocus(); showKeyboard(true); } return super.onTouchEvent(event); } public void showKeyboard(boolean show) { InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); if (show) { imm.showSoftInput(this,

How to update extracted text in a custom editor view

旧街凉风 提交于 2019-12-10 11:54:50
问题 I've created a custom editor for vertical Mongolian text. The circled views show my my custom editor. They keyboards at the bottom are system keyboards. When a system keyboard inputs text into it in landscape orientation, though, the keyboard will likely show an extracted text view rather than my custom editor view. The circled view below is the extracted text view (which is not getting updated by my custom editor). I need to somehow send updates from my view to the input method manager. This

Make INVISIBLE View handle touches as ACTION_OUTSIDE

℡╲_俬逩灬. 提交于 2019-12-10 11:41:52
问题 I want to create transparent system overlay window, which has several round views: Green view is VISIBLE , red one is INVISIBLE . The thing is that I need red view to pass touches to the underlying window, but by default it doesn't. I tried setting visibility of red view to GONE , but then overall size of containing view changes. Since I need the containing view to be snapped to the right edge of the screen, this means that position of green view changes, and I don't want this. Is there any

Custom Layout Manager using predefined and developer-defined child view(s)

好久不见. 提交于 2019-12-10 10:26:24
问题 Revised Question When one looks online in tutorials, or by Google IO presentations, there are always just 2 kinds of UI customizations that one can do (but there are several implementations of doing each type). These customizations are: Creating a custom view that is a composite of existing views, or your own Creating a custom layout that is your own However, what if I wanted to create a hybrid of these two? Specifically a Custom View that allow child views to be laid out how I define? There

Showing right layout in the editor for Custom Views in Android studio

情到浓时终转凉″ 提交于 2019-12-10 09:36:04
问题 I'm experiencing a strange behavior of the layout preview in Android Studio. I've developed a custom view extending an AppCompatButton and the layout is the expected one at runtime, however, the layout in the layout preview is not displaying correctly. In particular, the button is displayed but without the background color set from the custom attribute and without the drawableStart (set in the custom view init according to a custom attribute named "social"). See the code below for additional