Changing the default font does not work - android

<TextView ... android:typeface = "monospace" />
This doesn't show any change in the IDE editor or in my phone.
I cant use all the default fonts, It doesn't work.
All the other attributes are working except typeface.
I reinstalled android studio but it didn't solve the problem.
Please let me what should I do.

If you mean that you want to change your font, go to your XML file add statement
android:fontFamily ="sans-serif"

Related

Android - textview doesn't show up

For some reason, my textview Add a base doesn't show up when I launch the app on my phone. I have no idea why, 'cause it is displayed on Android studio :O
Replace tools:text="#string/add_base" with android:text="#string/add_base"
Attributes in the tools namespace are shown only when designing layouts. When you build your app, the build tools remove these attributes so there is no effect on your APK size or runtime behavior.
Reference: https://developer.android.com/studio/write/tool-attributes
tools:text="YOUR TEXT" can be used for your design and preview purpose.
If you add any text as a tools:text app will not use this text as that is not the actual text that should be rendered on the app
So instead of this, you should use android:text="YOUR TEXT"

Does Android Studio Linter Offer An Option to look for default XML layout values?

1.) Is there any reason to have a default value inside an android xml layout?
Ex.) The TextView below has included a default value of
android:visibility="visible"
`<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="visible"/>`
Conjecture: Because this is a default value, it has no effect, and therefore is an unnecessary line of code in the XML file. Is that line of thinking correct?
2.) If there is no reason for default values to exist in Android xml files, is there a lint plugin available to point out default value code lines in android XML files?
It is my thought that a large number of code lines in XML files are default values, serving no purpose. What can we do to reduce these lines of code?
U can create a style with your default values and use it.
For example:
<style name="DefaultTextViewStyle">
<item name="android:visibility">visible</item>
</style>
to use this:
<TextView
style="#style/DefaultTextViewStyle" />
I had some hope that the Lint inspection Redundant default value attribute assignment for xml, run via Android Studio might have done what you're asking. You can run it as specified under the Manually Run Inspections part of the Android docs. i.e.Android Studio -> Analyze -> Run Inspection by name -> enter "Redundant default value attribute assignment", then select the scope for the Lint check.
Sadly though, it doesn't pick up the case you mention above. I'm just wondering if there's something I've missed, or if this isn't intended for Android xml in some way?

In Android Studio, set android:text from strings.xml, but back to text later

I set android:text like below
android:text="#string/app_name"
But it will be changed to the following format later.
android:text="TestApp"
How to resolve it in Android Studio?
Many thanks!
This is a feature of android studio. It looks up the value of the resource and previews it for you so you don't have to go to the resource file and look it up manually.
It is only a visual preview. It does not affect your code/xml in any way.

Android - Cannot change textcolor from xml

I'm stuck with a very strange issue.
I can't change the TextColor of some TextViews around the app, neither with the android:textColor="" nor by setting a style. It only works if I change it at runtime. This problem appeared without any change related to the activity in question. The most strange thing is that in the Preview the colors are fine, but when I run it, the colors are always the same.
What might be overriding the textColor value set in the XML ?
Thx Anticipately
P.S:
Along all the App I can only change the color of the textHint
I had to remove all the N preview stuff from my sdk to make things normal again. Don't forget the cache too.
sdk/extras/android/m2repository/com/android/support/design|support-v-13|ect./24~
The syntax of xml line you wrote is wrong
instead of
android:setTextColor=""
use
android:textColor=""
You can change the Text Color in layout XML by using android:textColor
example:
android:textColor="#0E0E9A"
it overrides the style.xml
the only way to override your layout.xml is by code
example:
mEditText.setTextColor(Color.DKGRAY);

Using android default buttons

I found these website http://androiddrawables.com/Buttons.html where you can check the differences between Android buttons .
How can I use them? If I type R.drawables.btn_star_big_on_pressed the editor says it couldn't find the resource.
How can I use those default Android images ?
I am using 4.0.
The only way I know how to use them is:
<ImageView
android:id="#+id/imageView"
android:layout_width="48px"
android:layout_height="48px"
android:src="#android:drawable/btn_radio" />
to check available buttons type first letter after drawable/.
Then navigate to the button and you will see the selectors.
You can do something like this,
android.R.drawable.btn_star
Default resources for UI components depend on the device and platform version that your app is running on. For your button's to use them you would want to simply not declare a background resource.
My advice is that you will go to the Android SDK folder/platforms/android-##/data/res/drawable-dpi and copy the icons from there into your own res folder.

Categories

Resources