The question for me is, can I create a post in the launch_background.xml file to display when the page loads? I just managed to load the image and change the background color, I work with Flutter.
picture my source here
The only way to use a text is to give it also as a Bitmap
<item android:bottom="25dp">
<bitmap
android:gravity="center"
android:src="#drawable/myText" />
</item>
where myText is just some text converted to an image (using paint or whatever)
Related
I am having trouble removing the white screen that appears before my splash screen. I saw many videos and followed their instructions but still, that white screen don't go away. I am a beginner so I don't have much knowledge to solve it, kindly help!
I am using initState to show the splash screen. I have also put my splash image inside the drawable folder and this is how my launch_background.xml file looks like:
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:color/black" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/splash" />
</item>
</layer-list>
Okay, so my problem was solved when I added my splash in styles.xml file:
<item name="android:windowBackground">#drawable/splash</item>
My goal is to show a splash screen while app initializes.
So I used this package : flutter_native_splash: 0.1.9
And as per flutter_native_splash documentation on pub.dev, I created this file as required:
flutter_native_splash:
image: assets/images/splash.png
color: "#ffffff"
fill: true
# android_disable_fullscreen: true
and in terminal i ran this command:
flutter pub run flutter_native_splash:create
the package generated me the images in drawable-hdpi, drawable-mdpi, drawable-xdpi, drawable-xxdpi, drawable-xxxhdpi
now i am able to use this splash screen successfully but the problem is that the generated image is very blurry on physical device when i test...
is there any guidelines on how to draw this image from the start?
its just a simple black image with centered text...lets say for examle "Splash Screen"
i use figma for drawing and i export the file as SVG.
so my questions are:
should i specify width and height for the canvas that i draw inside?!
should i specify a fixed font size for the text...if so...suppose that there are two texts...centered one...and a subtitle beneath it.
i manipulated the font size many times but every time the generated image is blurry...
any help would be much appreciated.
Edit:
this is screenshot from figma while i am drawing the image:
figma screenshot
1.) Make a splash screen background image of size 1080*1920, add it into the drawable folder (android/app/src/main/res/drawable).
2.) Add below code into your android's styles.xml
<resources>
<style name="LaunchTheme" parent="#android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">#drawable/splash</item>
</style>
<style name="NormalTheme" parent="#android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">#drawable/splash</item>
</style>
</resources>
3.) Add below code in AndroidManifest.xml inside tag
android:name="io.flutter.app.FlutterApplication"
4.) Add meta-data in your first activity.
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme" />
I have set an image in launch_background.xml file for splash screen. it takes around 5sec to switch to next page. how to reduce display time.
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <item android:drawable="#android:color/white" />-->
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#mipmap/splash_screen" />
</item>
</layer-list>
Please suggest how to reduce display time?
I think you are running app in debug mode so it will take time. I will suggest you run the app in release mode. by running this command in terminal.
flutter run --release
By default, flutter run compiles to debug mode. Your IDE supports this mode. Android Studio, for example, provides a Run > Debug… menu option, as well as a green bug icon overlayed with a small triangle on the project page.
Read more about Flutter's build modes here
I'm developing a custom control and would like to use same color ListView control uses to highlight selected item.
I tried to use context.getResources().getDrawable(android.R.drawable.list_selector_background)
and then use setBackgroundDrawable() on my view, but the background is still transparent.
I don't want to use states and I just need a color value or drawable I can use on my control as a background.
Please help!
I think the best option is to use a selector like that on your xml on your listview:
<ListView
....
android:listSelector="#drawable/selectable_background"
..../>
Then on you drawable folder you add an xml file like this :
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="#android:integer/config_mediumAnimTime" >
<item android:state_pressed="false" android:state_focused="true"
android:drawable="#drawable/list_focused" />
<item android:state_pressed="true"
android:drawable="#drawable/pressed_background" />
<item android:drawable="#android:color/transparent" />
</selector>
and again on your drawable folder you add this other xml file:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#color/green" />
</shape>
and on your drawable-hdpi you add this 9-patch file (change the color or the file or use this web to create your own one http://android-holo-colors.com/):
https://dl.dropboxusercontent.com/u/33565803/StackOverFlowExamples/list_focused.9.png
Like this you should be able to have your customise highlight color on your listview.
EDIT:
Background of the clickable view :
android:background="#drawable/pressed_button"
Selector for the default ListView highlight color (pressed_button.xml inside drawable folder):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:drawable/list_selector_background"
android:state_pressed="true" />
<item android:drawable="#android:color/transparent"
android:state_focused="true" />
<item android:drawable="#android:color/transparent" />
</selector>
Well the list selector drawable is (usually) transparent in its default state. So you have to change the state first.
The pressed state could be used for example:
Drawable drawable = context.getResources().getDrawable(android.R.drawable.list_selector_background);
drawable.setState(new int[] {android.R.attr.state_pressed});
x.setBackgroundDrawable(drawable);
Where x is your view.
You can try like this,
For example you need the get the list item view by using below code
int visiblePosition = listview.getFirstVisiblePosition();
View view = listview.getChildAt(1 - visiblePosition);
// To get the color of particular listview item and set it,
View newView = listview.getChildAt(5 - visiblePosition);
newView.setBackgroundColor(((ColorDrawable) view.getBackground()).getColor());
Is it possible to change the color of the radio button in the Android spinner widget. By default it displays the green color for the radio button.
I need to change it to some other color, is it possible, and how?
I know this is an old question now, but here goes...
You will need to create a custom Theme and apply it to the Activity with your spinner.
First, you need to create images for the checked/unchecked states of the 'new' radio, you could just pull the given images btn_radio_on.png and btn_radio_off.png from the sdk's res/drawable-* folder(s). Edit them to look how you want (such as changing color or whatever) and save off to your project.
Next, create a new xml file in your res/values folder, and add the following:
<resources>
<style name="CustomSpinnerRadioTheme" parent="#android:style/Theme">
<item name="android:spinnerDropDownItemStyle">#style/EditedRadio</item>
</style>
<style name="EditedRadio" parent="#android:style/Widget.DropDownItem.Spinner">
<item name="android:checkMark">#drawable/edited_radio</item>
</style>
</resources>
Then, create another xml file in res/drawable named edited_radio.xml, and it should contain the following:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="#drawable/btn_radio_off" />
<item android:state_checked="true" android:drawable="#drawable/btn_radio_on" />
</selector>
just be sure to reference your edited images for the checked states. Then you just have to apply the CustomSpinnerRadioTheme to your Activity and run!
A good resource I found is Applying Styles and Themes especially the additional reference on Android Styles (styles.xml) and Android Themes (themes.xml)