android-xml

How to Change CardView background color from a theme

泄露秘密 提交于 2021-02-10 20:27:06
问题 In an app that has multiple themes, how would you change the background color of the CardView from the styles file? styles.xml <style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimaryTheme1</item> <item name="colorPrimaryDark">@color/colorPrimaryDarkTheme1</item> <item name="colorAccent">@color/colorAccentTheme1</item> </style> <style name="AppTheme2" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color

How to draw a vertical line in “android Horizontal Progress bar”

蹲街弑〆低调 提交于 2021-02-04 13:59:23
问题 I need to make a custom horizontal progress bar like the image given below. And I have designed the the progress bar like the image below using layer-list in drawable: I want to draw a vertical line when progress is greater than 25 like the image that I need. I wrote this code but it didn't work. myProgressBar = (ProgressBar) findViewById(R.id.progress); Canvas canvas = new Canvas(); Paint p = new Paint(); p.setStrokeWidth(2); p.setColor(Color.WHITE); canvas.drawLine(a, b, c, d, p); if

Android Studio shows some mess in xml files

人走茶凉 提交于 2021-01-27 10:41:16
问题 While I was working with my android project I wanted to edit one of my xml files. So I just opened it and this is what I saw: <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="CMakeSettings"> <configurations> <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> </configurations> </component> <component name="PropertiesComponent"> <property name="android.sdk.path" value="$USER_HOME$/AppData/Local/Android/Sdk" /> <property name="settings.editor.selected

Padding doesn't work on some devices

无人久伴 提交于 2021-01-27 03:54:31
问题 I had a strange problems during the set padding to EditText . xml looks like this: <EditText android:layout_width="270dp" android:layout_height="55dp" android:ems="10" android:id="@+id/etEmail" android:textStyle="bold" android:layout_gravity="center_vertical" android:textColor="#FFFFFF" android:hint="Or Use your Email" android:inputType="textEmailAddress" android:layout_alignLeft="@+id/textView6" android:layout_alignStart="@+id/textView6" android:textColorHint="#FFFFFF" android:background="

Padding doesn't work on some devices

耗尽温柔 提交于 2021-01-27 03:54:29
问题 I had a strange problems during the set padding to EditText . xml looks like this: <EditText android:layout_width="270dp" android:layout_height="55dp" android:ems="10" android:id="@+id/etEmail" android:textStyle="bold" android:layout_gravity="center_vertical" android:textColor="#FFFFFF" android:hint="Or Use your Email" android:inputType="textEmailAddress" android:layout_alignLeft="@+id/textView6" android:layout_alignStart="@+id/textView6" android:textColorHint="#FFFFFF" android:background="

Android XML Is there a way to use the tool namespace with custom attributes?

自闭症网瘾萝莉.ら 提交于 2021-01-26 03:13:09
问题 I've created a custom view with attributes. Is there a way to use those attributes with android tools in Android studio? for example : <MyOwnCoolView android:layout_width="96dp" android:layout_height="96dp" android:padding="3dp" tools:dividerAngle="2"/> Where the attr file is : <resources> <declare-styleable name="MyOwnCoolView"> <attr name="dividerAngle" format="float"/> </declare-styleable> 回答1: My opinion is that you can't. There's an official, though very old, page here that quotes:

How to add padding before CheckBox/RadioButton across API levels

允我心安 提交于 2021-01-24 14:05:03
问题 I want to add padding to the left/start of RadioButton and CheckBox views. The motivation for this is to have full width selectable lists (for select one and select multiple) where the radio button or check box element have space between themselves and the screen edge but also don't end up with a non clickable area where that space is. For API 16 and below I can add the spacing AND maintain clickability I can use the view's paddingLeft attribute. For API 17 and above this attribute controls

Call requires API level 16 (current min is 14)

不羁的心 提交于 2021-01-04 04:17:31
问题 I have this line in my code: linearLayout.setBackground(drawable); setBackground() shows the following error: Call requires API level 16 (current min is 14) What does this mean? Can I raise my API level? What does a higher/lower API level mean? Does it limit the amount of devices my app can be used on if the API level is higher? 回答1: What does this mean? It means that the setBackground(Drawable) method was added in API Level 16, and older devices do not have it. However, your app's

Remove empty icon spaces on androidx preferences

久未见 提交于 2020-12-12 06:16:05
问题 I have just migrated my project to use androidx libraries. The new preferences/Settings Screen now displays empty icon spaces as shown in the picture here. I tried the official documentation with no luck. How to remove the empty icon spaces before preferences? 回答1: You can remove the empty icon space with this: app:iconSpaceReserved="false" 来源: https://stackoverflow.com/questions/54394971/remove-empty-icon-spaces-on-androidx-preferences

RecyclerView adapter showing wrong images

自古美人都是妖i 提交于 2020-11-30 09:19:42
问题 I have a RecyclerView adapter that looks like this: public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> { private static Context context; private List<Message> mDataset; public RecyclerAdapter(Context context, List<Message> myDataset) { this.context = context; this.mDataset = myDataset; } public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnCreateContextMenuListener, View.OnClickListener { public TextView title; public LinearLayout