My primary problem is I want to increase the size of the thumb of the Seekbar, so I found this post: Changing size of seekbar thumb
From there it said i can create thumb_size.xml and add the below code inside:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<size
android:height="40dp"
android:width="40dp" />
<solid android:color="#android:color/transparent" />
</shape>
</item>
<item android:drawable="#drawable/scrubber_control_normal_holo"/>
However then the Android Studio give me error message saying that it cannot find the
scrubber_control_normal_holo
Then I find this post: Android: Where to find the RadioButton Drawable?
However in my SDK folder /platforms/android-17/data/res/drawable folder, I still cannot find this file, I can only find something like:
seek_thumb.xml
but when I try to use it, it still give me error.
At last I can find the resource images in the following folders (for different device size):
SDK folder\platforms\android-17\data\res\drawable-hdpi
SDK folder\platforms\android-17\data\res\drawable-mdpi
SDK folder\platforms\android-17\data\res\drawable-xhdpi
SDK folder\platforms\android-17\data\res\drawable-xxhdpi
SDK folder\platforms\android-17\data\res\drawable-xxxhdpi
Related
I am trying to get a glow effect like the background for edittext
I tried doing it but the background is not as much effective as the image
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#68F30606"/>
<corners android:radius="10dp" />
</shape>
</item>
<item
android:left="1.7dp"
android:right="1.7dp"
android:top="1.7dp"
android:bottom="1.7dp">
<shape android:shape="rectangle">
<solid android:color="#android:color/white"/>
<corners android:radius="10dp" />
</shape>
</item>
</layer-list>
Can someone help me to solve this mystery?
Then you will need to use the old-technique(kind of) of 9-Patch Drawing. I used to do it too. Examples are scarce because they are big, but there is documentation.
Documentation: https://developer.android.com/studio/write/draw9patch.
Also, if this helps you can check this too: Outer glow in edittext
To use the 9-Patch images in Xml to this (remember this is after you have created the 9-Patch Images):
Reference the drawable with the name but don't include .9.png (auto-complete in eclipse will take care of this)
Make sure you only have 1 image under the main /drawable folder (not a version for each dpi folder)
The image must be specified using :background, not :src (this got me stuck for a while)
android:background="#drawable/splash_logo"
Make sure the image and layout that contains it are using:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Credit To: Creating & Using 9-patch images in Android
Also, check this website out, it contains a lot of useful examples that the documentation doesn't provide:
https://tekeye.uk/android/examples/ui/android-9-patch-image-files
This is my first venture into writing any kind of code, let alone an android app. I created the project with the compileSdkVersion of 28, targetSdkVersion of 28 and minSdkVersion of 23. The app will only run on Android Pie and crashes on any previous version I have tried to install it on.
Everything compiles properly and works wonderfully on the emulator and my personal phone (both on Pie). I have read a lot about using the Android Support Library, however, I have not seen any information on how to understand which parts of your code need to use things from the support library versus the framework. Android Studio may have given me warnings along the way about using things from the support library, but being new at this, I did not know what it meant or what my proper choice should be. Now that I understand, I don't know how to attack going back and finding (and then fixing) anything that needs to use the support libraries.
I imported com.android.support:appcompat-v7 and have used AppCompatActivity instead of Activity. In a nutshell, I use textViews, editTexts, spinners and a TabHost (with two tabs). I think that the ActionBar might be a problem as well, but do not know how to see if that is the problem and how to fix it.
The rest of the code is mathematical calculations with a bunch of if/then/else statements and some switch statements.
The app force closes when it is opened after being installed on any OS prior to Android Pie.
Snippet from content_main.xml (layout):
<Spinner
android:id="#+id/spnFromPool"
android:layout_width="176dp"
android:layout_height="34dp"
android:layout_gravity="start"
android:layout_weight="0.3"
android:background="#drawable/bg_spinner"
android:entries="#array/pool_type_array" />
bg_spinner.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#color/swimToolPrimary"/>
<corners android:radius="10dp" />
<stroke android:color="#000000" android:width="1dp" />
</shape>
</item>
<item android:gravity="center_vertical|right" android:right="8dp">
<layer-list>
<item android:width="12dp" android:height="12dp" android:gravity="center" android:bottom="10dp"
tools:targetApi="m">
<rotate
android:fromDegrees="45"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#color/swimToolSecondary" />
<stroke android:color="#color/swimToolSecondary" android:width="1dp"/>
</shape>
</rotate>
</item>
<item android:width="20dp" android:height="10dp" android:bottom="21dp" android:gravity="center"
tools:targetApi="m">
<shape android:shape="rectangle">
<solid android:color="#color/swimToolPrimary"/>
</shape>
</item>
</layer-list>
</item>
</layer-list>
You can check the problem in log of android studio by selecting "No Filters" in top-right corner in logcat and for filtering the data you can add package name of your app in search bar.
I'm making a very basic test app in Android Studio. I am creating an xml file for a button pressed event, but for some reason it is not highlighting any keywords. I have updated android studio. I am at a loss for how to solve this, as it's a new process to me.
The message the lightbulb gives me is "Unexpected text found in layout file" when I try to define these attributes for the bt_pressed XML.
Make sure your attribute is nested properly in the tag. Like this:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#color/some_color" />
</shape>
(hint: look at the > character in your provided snippet)
Incorrectly placed ">" in line 2.
I made the rectangle below for a project recently and it worked just fine. Nest it in the in between your first shape tag.
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="rectangle">
<corners android:radius="3dip" />
<solid android:color="#color/colorTwo" />
</shape>
</shape>
Alternatively, don't nest anything and change your opening shape tag to this:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
I've experienced a strange effect dealing with shape drawables with support lib attributes. I have following code, which crashes every time during inflation.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="26dp" android:height="26dp"/>
<solid android:color="?attr/colorPrimary"/>
Note I have used ?attr/colorPrimary as color. If I use
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="26dp" android:height="26dp"/>
<solid android:color="#color/primary"/>
It is working fine without any crashes. Issue is only in devices running lower version of Android than 5.0. I am using following support lib
compile 'com.android.support:support-v4:22.2.1'
Anyone found reason why this is happening? Is this a bug in support library?
<solid android:color="?attr/colorPrimary"/> Points to a private color (was not public) in Android code, maybe it doesn't exist in some API.
While <solid android:color="#color/primary"/> will point to a color in your project, maybe you have a color name primary only in folder values-v21 so it's only crashing in versions below 5.0
I think you should try using this:
<solid android:color="#android:attr/colorPrimary"/> to make sure the attribute exists.
Hope this helps.
I'm building a simple mono android app. I've designed a simple style to set the background of a textview:
The xml file in my Resouces/Drawable Folder:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#DD2ECCFA" />
<stroke android:width="1dp" android:color="#FFFFFFFF" />
<corners android:radius="7dp"/>/>
</shape>
I get the following message in vs 2012:
couldn't find schema information for the element 'shape'.
And a couple more messages for corners, stroke, solid...
This message causes problem when I install the app on a real device but on the emulator every thing is fine.
I'm using java jdk version 6. Thanks. Any help will do.