I have made the splash screen from the manual:
I have created SplashActivity that extends from AppCompatActivity etc. Its works as expected.
But now I want set some animation to the splash activity and I am confused, because all that I put on the SplashActivity is unvisible (and now I cann't be to sure that the itself SplashActivity is visible).
Now I have deleted all excess stuff from the SplashActivity and start it as is:
// `MainLauncher` argument for my MainActivity is false now
[Activity(Theme = "#style/SplashTheme", NoHistory = true, MainLauncher = true)]
public class SplashActivity : Activity // AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState) // , PersistableBundle persistentState
{
base.OnCreate(savedInstanceState); // persistentState
this.SetContentView(Resource.Layout.LPreloader);
}
protected override void OnResume()
{
base.OnResume();
}
}
LPreloader.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
android:id="#+id/my_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Some element on Activity" />
</LinearLayout>
Theme in styles for the activity is:
<style name="SplashTheme" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
I want to see for example the my_button on activity, but I have nothing. More than that: I set breakpoint on the line base.OnCreate(savedInstanceState); and its never stopped on it. I see just logo from #drawable/splash_screen and nothing.
If I create new Xamarin.Android project with same code - it works fine (I see the button). I cann't understand it. What is hinder to working in Xamarin.Forms project?
Remove Window background from splash theme and try it will work, as you except
<style name="SplashTheme" parent ="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">#color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
Related
Any one could suggest how to reduce space between spinner items height having radio buttons.
My Code is below .
Layout
<Spinner android:layout_width="250dp"
android:layout_height="40dp"
android:id="#+id/spinnerCompany"
android:theme="#style/SpinnerTheme"
android:background="#android:drawable/btn_dropdown" />
Spinner Theme
<style name="SpinnerTheme">
<item name="android:layout_width" >fill_parent</item>
<item name="android:textSize" >15dp</item>
<item name="android:layout_width" >fill_parent</item>
<!--<item name="colorAccent">#00f</item>
<item name="colorControlNormal">#00f</item>-->
</style>
Activity Code
ArrayAdapter CompanyAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, cls_static.ToArrayList(ListofCompnyFromDB));
CompanyAdapter.SetDropDownViewResource(Android.Resource.Layout.SelectDialogSingleChoice);
spinnerCompanyObj.Adapter = (CompanyAdapter);
Getting output like below any help would be appreciated.
You can add the android:dropDownWidth="100dp" in Spinner
<Spinner android:layout_width="250dp"
android:dropDownWidth="100dp"
android:layout_height="40dp"
android:id="#+id/spinnerCompany"
android:theme="#style/SpinnerTheme"
android:background="#android:drawable/btn_dropdown" />
There is running screenshot.
I have made a minor change like below and it get resolved.
Activity
CompanyAdapter.SetDropDownViewResource(Resource.Drawable.styl_spinner_style);
styl_spinner_style
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="37dp"
android:ellipsize="marquee"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:textColor="#252c3b"/>
Hello to all programmers. I try to create Android app in Visual Studio Xamarin. I placed EditText in the lower part of app screen and when I set focus on it, keyboard hide bottom part of UI. Is it possible to do something with this?
Screens:
Code:
Main.axml
MainActivity.cs
All help will be appreciated
UPDATED
Theme code:
<resources>
<style name="CustomToolbar" parent="#android:style/Theme.Material.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:colorPrimaryDark">#color/status_bar</item>
<item name="android:statusBarColor">#color/status_bar</item>
<item name="android:colorPrimary">#color/status_bar</item>
</style>
<style name="TransparentStatusBar" parent="#android:style/Theme.Material.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="CustomSplash" parent ="#android:style/Theme.Material.Light">
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
You can put your layout inside ScrollView. I will allow EditText to be fully visible, but it will not do anything with bottom buttons since they do not block that field.
If you want to make it more pressure for eyes, you can scroll ScrollView when the keyboard is presented on the screen.
EDIT:
To find out when the keyboard appears, you can use GlobalLayout event of the main layout.
ViewTreeObserver vto = element.ViewTreeObserver;
vto.GlobalLayout += (sender, args) => {
element.Height; // will be different with/without keyboard
};
I'm run into some problems on another project I'm working on, so I created a new project to see if I'm getting the same errors, which I am.
I've created a button inside main.axml, which I'm trying to style using somestyle.xml.
somestyle.xml:
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- What to do when the button is NOT pressed -->
<item android:state_pressed="false">
<layer-list>
<item android:right="5dp" android:top="5dp">
<!-- Shape the button -->
<corners android:radius="20dp"/>
<solid android:color="#d13838"/>
</item>
<item android:bottom="2dp" android:left="2dp">
<shape>
<gradient android:angle="270" android:endColor="#d13838" android:startColor="#d13838"/>
<stroke android:width="1dp" android:color="#d13838"/>
<corners android:radius="4dp"/>
<padding android:bottom="0dp" android:left="10dp" android:right="10dp" android="10dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
I'm getting a bunch of warnings:
However, the application builds but throws an exception on
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
in MainActivity.cs
Unhandled Exception:
Android.Views.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class android.widget.Button occurred
Main.axml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/btn"
android:text="Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/somestyle" />
</LinearLayout>
MainActiviy.cs:
using Android.App;
using Android.Widget;
using Android.OS;
namespace TestNamespaceBug
{
[Activity(Label = "TestNamespaceBug", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
}
}
}
I can't figure out what's causing all the warnings + the exception. Greatly appreciate any suggestions on how to solve this.
I have been having problems with incorporating a Progress Bar into my splash screen. I have an XML file called splash_setup,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background">
<bitmap
android:src="#drawable/splash"
android:tileMode="disabled"
android:gravity="top|center_horizontal" />
<ProgressBar
style="#android:style/Widget.ProgressBar.Small"
android:gravity="top|center_horizontal" />
</LinearLayout>
This file is used as background for 'splashTheme' (in Styles.XML) as following,
?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="splashTheme" parent="android:Theme">
<item name="android:windowBackground">#drawable/splash_setup</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
The splashTheme is used in splashActivity (the splash executes database initialisation and then finished),
[Activity(Label = "#string/appName", Theme = "#style/splashTheme",
MainLauncher = true, NoHistory = true)]
So to my problem... the splash_setup code runs fine without tags, but when they are in I get the following error,
android.content.res.Resources$NotFoundException: File res/drawable/splash_setup.xml from drawable resource ID #0x7f020002
Could anyone point out what I am doing wrong? Thanks!
What you have is a layout not a drawable. android:windowBackground attribute in style allows only drawable which may include shapes and/or layer lists. If you really wish to show a progressbar, then you need an activity.
Hello Everyone
There are many threads avilable in this case ... I was tried everything but no luck .
I was new to android background..Iam c# guy,now iam work with xamarin droid...So can anyone explain what is the error.this solution not working only **PRE lolipop devices **.
My layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/quickreturn_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/masonry_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
I was Use appcompact Theme
Values/Style.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="Theme.Splash"
parent="#android:style/Theme.Holo.Light">
<item name="android:windowBackground">#drawable/splashscreen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="AppTheme" parent="Base.Theme">
</style>
<style name="Base.Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/DarkOrangeLight</item>
<item name="colorPrimaryDark">#color/DarkOrange</item>
<item name="colorAccent">#color/DarkOrangeAcent</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowBackground">#color/bg</item>
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">false</item>
<item name="windowNoTitle">true</item>
<!-- Customize your theme here. -->
</style>
</resources>
Values-21 \styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="AppTheme" parent="Base.Theme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#color/DarkOrange</item>
</style>
</resources>
My Main Activity
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
try
{
SetContentView(Resource.Layout.MansoryLayout);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
i got error on setcontentview Method once called ....
Detailed exception IS:
{Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00084] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029
at Android.App.Activity.SetContentView (Int32 layoutResID) [0x00070] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.App.Activity.cs:5500
at test.Droid.Activity.MoviesActivity+<OnCreate>d__16.MoveNext () [0x00041] in E:\project\test\test\test\test.Droid\Activity\MoviesActivity.cs:92
--- End of managed exception stack trace ---
android.view.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.AppBarLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at md57bfe09fe2721efc565bcf4b957f437a7.MoviesActivity.n_onCreate(Native Method)
at md57bfe09fe2721efc565bcf4b957f437a7.MoviesActivity.onCreate(MoviesActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2151)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5095)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
... 23 more
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0b00d9 a=2 r=0x7f0b00d9}
at android.content.res.Resources.loadDrawable(Resources.java:2068)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.support.design.widget.AppBarLayout.<init>(AppBarLayout.java:139)
I have added package to my solutions are
Design Support Libiary
Appcompact v7
Appcompact v7 Recyerview
Support libiary V4
i have attached screen shoot of error Message
You probably extend Activity not AppCompatActivity.
Also, your theme needs a proper parent.
<style name="AppTheme" parent="Theme.AppCompat">
Also make sure you have this call:
protected override void OnCreate(Bundle bundle)
{
SetTheme(Resource.Style.AppTheme);
base.OnCreate(bundle)
This solved my problem.
complementing Demian you can also use with annotation
[Activity(Theme ="#style/AppTheme")]
public class MainActivity : AppCompatActivity {
....
}
I had the same problem. And it happened after updating all support library to version 23.4.0.1 from 23.1.1.1. I solved it by downgrading these libraries.