sorry for my english.
I made my first app very simple (web view with splash screen) for try and understand something basic function of android programming.
But when I build app-debug (directly on my smartphone), facebook start to crash continually.
I tried to leave only basic structure, commenting the rest
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
but, facebook continue to crash.
This is the log.
Someone can help me about this funny/annoyng issue?
This is activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<WebView
android:id="#+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:src="#drawable/sad_android"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_margin="80dp" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imageViewSplash"
android:src="#drawable/splash"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
Related
I've search thoroughly but it doesn't appear that this is a common problem -- this may be increased by the fact that I'm still new and don't really know what to look for in this regard.
Regardless, the last time that I ran this code it worked fine however, now the display is simply white -- so even with the black writing it doesn't show up. Thank you very much for any help you can offer.
The xml code is below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="#drawable/background" />
<TextView
android:id="#+id/mocha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/price_mocha"
android:layout_alignParentStart="true"
android:layout_marginStart="15dp"
android:text="Price of mocha"
android:textColor="#060505" />
<TextView
android:id="#+id/price_mocha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="234dp"
android:layout_marginStart="35dp"
android:text="3.99"
android:textColor="#ffffff" />
</RelativeLayout>
I wrote some very simple code with one image and two text views in a Relative Layout.
It all seems fine in the preview but as soon as I try to run the code on my phone, one text view disappears.
I have tried everything, but can't fix the problem (check out the screenshots).
Code in Android Studio Preview
Code on my smartphone
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/image_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/hb_isabel"
android:contentDescription="TODO"
android:scaleType="centerInside"
android:src="#drawable/androidparty"
/>
<TextView
android:id="#+id/hb_isabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Happy Birthday,Isabel!"
android:textSize="36sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="From, Nathalie"
android:textSize="36sp"
/>
</RelativeLayout>
Is there anyone who can help me out?
i got a very weird type of problem while developing a basic android app.
While I've created an app in which the background image of an app is visible to all the devices except nexus devices of android marshmallow. Kindly help me in solving the error.
Below is the code and screenshot attached.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/abst"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="project.scytech.mi_agenda.LoginActivity">
<include
android:id="#+id/linearLayout"
layout="#layout/appname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/loginLayout"
android:layout_centerHorizontal="true"
android:orientation="horizontal" />
<LinearLayout
android:id="#+id/loginLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="16dp">
<EditText
android:id="#+id/editTextDomainName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/domainName"
android:inputType="textUri"
android:textColorHint="#FFF8E5" />
<EditText
android:id="#+id/editTextUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/username"
android:textColorHint="#FFF8E5" />
<EditText
android:id="#+id/editTextPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="#string/username"
android:hint="#string/password"
android:inputType="textPassword"
android:textColorHint="#FFF8E5" />
<Button
android:id="#+id/buttonLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginTop="16dp"
android:clickable="true"
android:onClick="loginClicked"
android:text="#string/login" />
</LinearLayout>
</RelativeLayout>
Please try to use an ImageView and set it as background.
It means:
Use a RelativeLayout or a FrameLayout and define your ImageView as the
first child. The first objects defined are the lowest in the z-order
(i.e. they will be "below" the other views).
From: Setting an ImageView to the background Android
To fit it to whole screen device use match_parent or android:scaleType="fitXY"
Your code should look like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#000000" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="42dp"
tools:ignore="ContentDescription" />
//Rest of widgets......
Check also: How to make image fill RelativeLayout background without stretching
It should work
Please help me! My App Background won't appear on my mobile device upon running the project.
What might be the problem? I already lessen the resolution of my background image but still no progress. The output won't appear. But if I remove the background it would appear instantly.
Here's the code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg"
tools:context=".MainActivity" >
<ImageView
android:layout_width="290dp"
android:layout_height="200dp"
android:src="#drawable/logo"
android:id="#+id/imageView"
android:contentDescription="#string/my_logo"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="12dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="240dp"
android:src="#drawable/mr_hertz"
android:id="#+id/mr"
android:contentDescription="#string/mr_hertz_"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="290dp"/>
<ImageButton
android:layout_width="140dp"
android:layout_height="40dp"
android:src="#drawable/account"
android:id="#+id/account"
android:layout_below="#+id/mr"
android:layout_centerHorizontal="true"
android:contentDescription="#string/my_account" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/member_"
android:textColor="#f0fffc"
android:id="#+id/member"
android:textSize="12sp"
android:textStyle="bold|italic"
android:layout_below="#+id/account"
android:layout_centerHorizontal="true" />
<ImageButton
android:layout_width="100dp"
android:layout_height="15dp"
android:src="#drawable/sign_in"
android:id="#+id/sign"
android:contentDescription="#string/sign_in_"
android:layout_below="#+id/member"
android:layout_alignLeft="#+id/member"
android:layout_alignStart="#+id/member" />
</RelativeLayout>
If your entire layout is empty, try removing:
tools:context=".MainActivity"
Otherwise, if your view appears correctly in the Graphical Layout part of the editor, something is wrong with your image. Try using another.
I have added admob codes for showing ads in my app. When i run the app in emulator it opens the splash screen and then the app suddenly exits saying "Unfortunately,Your app has stopped". I don't know why it is showing. It works well before addding the admob codes.I have also added the code. help me with this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"``
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background2" >
<ScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="60dp"
android:background="#null"
android:padding="30dp"
android:src="#drawable/menu1"
android:contentDescription="#string/image_desc" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageButton1"
android:background="#null"
android:padding="30dp"
android:src="#drawable/menu2"
android:contentDescription="#string/image_desc" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageButton2"
android:background="#null"
android:padding="30dp"
android:src="#drawable/menu3"
android:contentDescription="#string/image_desc" />
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageButton3"
android:background="#null"
android:padding="30dp"
android:src="#drawable/menu4"
android:contentDescription="#string/image_desc" />
<ImageButton
android:id="#+id/imageButton5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageButton4"
android:background="#null"
android:padding="30dp"
android:src="#drawable/menu5"
android:contentDescription="#string/image_desc" />
</LinearLayout>
</ScrollView>
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="admob id"
ads:adSize="SMART_BANNER"
ads:loadAdOnCreate="true"/>
</RelativeLayout>
there might be a some problem with adding googleadmobsdk cross check yourself with this link visit https://developers.google.com/mobile-ads-sdk/docs/#android.
I think that i can find at least one problem in your application, you are missing one impotant field in your admob specification, you must add that line in your layout:
ads:adUnitId="yourunitid"
In order to obtain yout unit id you must register your app to admob site, here: http://www.admob.com/my_sites/create_site
Another thing that you must consider, is that if you had just inserted the app, the banners usually show only after few hours.
Finally, i suggest you to add that line in your layout:
ads:testDevices="TEST_EMULATOR"
With that you are saying to admob to send only "test" banner to your device (this prevent the risk to be banned)
So your adView should be like:
then if it doesn't help add your logcat output.