android-styles

Android Toolbar: small title text in landscape mode

自古美人都是妖i 提交于 2019-11-27 03:10:47
I'm testing the new Toolbar and AppCompat theme on Android and ran into a problem. My toolbar title text looks normal-sized on portrait mode but it became rather small on landscape mode although I didn't do anything in the code to change the title's text size. Here are the screen shots: activity_main.xml: <!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. --> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:android=

Get the Theme value applied for an activity programmatically

 ̄綄美尐妖づ 提交于 2019-11-27 02:32:30
问题 I want to know which theme is applied for an Activity in an application. Normally we are setting the theme by using setTheme(android.R.style.Theme_Light); Here we are specifying style, As like this can we able to get the specific style type exactly applied for an activity programmatically. Thanks 回答1: Context class has a nice method called getThemeResId , however it's private thus you need to use reflection. Here's an example: @Override protected void onCreate(Bundle savedInstanceState) {

Creating styles-v21.xml

心已入冬 提交于 2019-11-27 01:46:07
问题 In Android Studio, I imported a project which did not include styles.xml (v21) . So I created a styles-v21.xml file in the values directory. Both styles.xml and styles-v21.xml are in the values directory now. styles.xml <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="AppTheme.Base"> <!-- Customize your theme here. --> </style> <style name="AppTheme.Base" parent="Theme.AppCompat.Light"> </style> </resources> styles-v21.xml <?xml version="1.0" encoding="utf-8"?

How to change the background color around a DialogFragment?

陌路散爱 提交于 2019-11-27 00:51:31
I'm building a custom DialogFragment . The dialog layout is set to my_dialog.xml , but how can I modify the color around the dialog (the transparent grey)? my_dialog.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" > <TextView android:id="@+id/hello" android:layout_width="100dp" android:layout_height="100dp" android:background="@android:color/holo_orange_light" android:gravity="center" android:text="hello" /> </RelativeLayout> MyDialogFragment.java public class

Android AlertDialog with rounded corners

梦想的初衷 提交于 2019-11-27 00:04:01
问题 I have been trying to make my Alert Dialog with rounded corners but somehow I am not able to. I have tried and I failed. I tried to follow this blog http://blog.stylingandroid.com/archives/271 and made my styles based on that. Btw, to add to my question now. Some of my new finding. The code in the above link just works fine on 2.3.3 (GB) but does not work at all in ICS . Some change made the code to break. I want to avoid creating 9 patch images and thus I am using shapes. 9 patch image is

Setting header color of app in overview (recent apps) screen

旧巷老猫 提交于 2019-11-27 00:03:50
问题 I'm adding some Lollipop-only styling to an app. I want to change color of header in overview screeen like Gmail here: I have figured out I can do <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:colorPrimary">@color/my_favorite_color</item> </style> to achieve it, but I would want to specify only the color for this case, just like I can do: <item name="android:statusBarColor">@color/my_favorite_color<item> Is there a specific attribute to set header's

MaterialComponents theme alert dialog buttons

感情迁移 提交于 2019-11-26 23:01:07
问题 Recently I switched from support library to com.google.android.material:material:1.0.0 But now I have a problem, in this pages there's a note https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md Note: Using a Material Components theme enables a custom view inflater which replaces default components with their Material counterparts. Currently, this only replaces Button XML components with MaterialButton. And the theme I am using Theme

How do you underline a text in Android XML?

馋奶兔 提交于 2019-11-26 22:37:14
问题 How do you underline a text in an XML file? I can't find an option in textStyle . 回答1: If you are using a string resource xml file (supports HTML tags), it can be done using <b> </b> , <i> </i> and <u> </u> . <resources> <string name="your_string_here"> This is an <u>underline</u>. </string> </resources> If you want to underline something from code use: TextView tv = (TextView) view.findViewById(R.id.tv); SpannableString content = new SpannableString("Content"); content.setSpan(new

AlertDialog styling - how to change style (color) of title, message, etc

ⅰ亾dé卋堺 提交于 2019-11-26 22:35:48
问题 I've breaking my head over this quite a bit. What I need to do is, change the style of all AlertDialog s in my android application - dialog background needs to be white-ish, and text needs to be black-ish. I tried creating a lot of styles, themes, and applying from the code, manifest, etc, but no success, with regard to the text colors inside the AlertDialog . Right now, I have the simplest of codes, set like this: Manifest: <application android:icon="@drawable/ic_launcher" android:label="

Is possible set Expanded Notification as default in Big Text Notifications?

浪子不回头ぞ 提交于 2019-11-26 19:56:59
问题 I followed this Sample Code In Big Text Notifications section, he said that need expand to see Big text notification form, as image im below : I wonder that we can not set Expanded Notification as default in Big Text Notifications? People who know it is can or not, If can, Please tell me how to do it, Thanks, 回答1: The documentation states: A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or