android-custom-view

How to test the Custom view performance

烈酒焚心 提交于 2020-12-09 06:41:48
问题 I want to test my Custom component UI rendering performance. I used the following test case to check the rendering performance. private long getLayoutTime(int layoutRes) { final Context targetContext = getInstrumentation().getTargetContext(); final LayoutInflater layoutInflater = LayoutInflater.from(targetContext); final long startTime = System.currentTimeMillis(); for (int i = 0; i < 1000; i++) { final View view = layoutInflater.inflate(layoutRes, null); view.setLayoutParams(new ViewGroup

How to show custom notification by default with collapsed layout when expand layout is enable in Android

a 夏天 提交于 2020-12-04 03:35:34
问题 I want to show my custom notification by support both small and large layout as screenshots above when user collapse or expand the notification. But the result it shows expanded notification by default. I want to show it as collapsed notification by default and only show expanded notification when user expand it. Please check my code bellow: private fun initCustomNotification() { // Get the layouts to use in the custom notification val notificationLayout = RemoteViews(packageName, R.layout

Android: Multiple view children for custom view with existing layout

╄→尐↘猪︶ㄣ 提交于 2020-07-16 16:20:41
问题 I have to build a more complex custom view in Android. The final layout should look like this: <RelativeLayout> <SomeView /> <SomeOtherView /> <!-- maybe more layout stuff here later --> <LinearLayout> <!-- the children --> </LinearLayout> </RelativeLayout> However, in the XML files I just want do define this (without defining SomeView, SomeOtherView etc.): <MyCustomView> <!-- the children --> </MyCustomView> Is this possible in Android, and if yes: What would be the cleanest way to do it?

Android: Is it possible to use string/enum in drawable selector?

笑着哭i 提交于 2020-07-05 05:26:46
问题 Questions Q1 : Has anyone managed to get custom string/enum attribute working in xml selectors? I got a boolean attribute working by following [1], but not a string attribute. EDIT: Thanks for answers. Currently android supports only boolean selectors. See accepted answer for the reason. I'm planning to implement a little complex custom button, whose appearance depends on two variables. Other will be a boolean attribute (true or false) and another category-like attribute (has many different

Android: Is it possible to use string/enum in drawable selector?

微笑、不失礼 提交于 2020-07-05 05:26:11
问题 Questions Q1 : Has anyone managed to get custom string/enum attribute working in xml selectors? I got a boolean attribute working by following [1], but not a string attribute. EDIT: Thanks for answers. Currently android supports only boolean selectors. See accepted answer for the reason. I'm planning to implement a little complex custom button, whose appearance depends on two variables. Other will be a boolean attribute (true or false) and another category-like attribute (has many different

multiline edittext where parts are not editable, like fill in the blanks

左心房为你撑大大i 提交于 2020-07-02 09:52:54
问题 I need to have a view which contains textview and edittext. Example: Yay! you made it to ______ We should hang out! feel ____ to follow me. Above "_____" could be of any length and it should feel like a paragraph in the end. Rest of the text given above is not changeable. Just like fill in the blanks. 回答1: From my perspective, a fill-in-the-blank widget should do the following: Allow only certain identified portions of the text to be changed. The rest of the text is locked. Not allow cursor

multiline edittext where parts are not editable, like fill in the blanks

筅森魡賤 提交于 2020-07-02 09:46:23
问题 I need to have a view which contains textview and edittext. Example: Yay! you made it to ______ We should hang out! feel ____ to follow me. Above "_____" could be of any length and it should feel like a paragraph in the end. Rest of the text given above is not changeable. Just like fill in the blanks. 回答1: From my perspective, a fill-in-the-blank widget should do the following: Allow only certain identified portions of the text to be changed. The rest of the text is locked. Not allow cursor

Android data binding - cannot find getter for <> that accepts parameter type 'long'

て烟熏妆下的殇ゞ 提交于 2020-06-28 02:51:17
问题 I have been using data binding for the past few weeks and now am trying to use a two way data binding for a custom view with a 'value' attribute. My problem is that I get the following error when building. Cannot find a getter for <com.twisthenry8gmail.dragline.DraglineView app:value> that accepts parameter type 'long' Now it was my understanding that the binding library will automatically use my public setters and getters however the most confusing part is adding a redundant inverse binding

Android Custom WebView With Rounded Corners

最后都变了- 提交于 2020-06-26 07:45:18
问题 I'm trying to make a custom WebView that is completely identical to a regular WebView except that it has rounded corners. The rounded corners need to be transparent because I'd like to put this WebView in a Dialog. I tried making my custom class like so: public class RoundedWebView extends WebView { private Context context; private int width; private int height; public RoundedWebView(Context context) { super(context); initialize(context); } public RoundedWebView(Context context, AttributeSet

Android Custom WebView With Rounded Corners

馋奶兔 提交于 2020-06-26 07:45:03
问题 I'm trying to make a custom WebView that is completely identical to a regular WebView except that it has rounded corners. The rounded corners need to be transparent because I'd like to put this WebView in a Dialog. I tried making my custom class like so: public class RoundedWebView extends WebView { private Context context; private int width; private int height; public RoundedWebView(Context context) { super(context); initialize(context); } public RoundedWebView(Context context, AttributeSet