So I've set up my Eclipse to have the Android SDK and ADT plugin.
I set up my AVD to have a Galaxy Nexus and Galaxy S2 emulator.
I've created a new Android project and I get my blank MainActivity which simply displays "Hello World!" which is the problem.
In the Graphical Layout, I delete the "Hello World!" text to remove it. I check in the activity_main.xml and the script containing the "Hello World!" text is no longer there. I run in either emulator and everything works, but when the app opens, "Hello World!" is still there.
Here's the xml now
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.project.MainActivity"
tools:ignore="MergeRootFrame" />
I've changed nothing except removing that text. The MainActivity.java has not been touched. Is there something I'm missing?
This was a little bit odd when it happened to me, just remove the Hello World Text View from the fragment.xml file and it should be fine.
that xml code is just for layout when you add smthg on layout this code will be bigger,example
<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: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=".MainActivity" >
<Button
android:id="#+id/bb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="72dp"
android:text="git" />
thats have only a button
your code has nothing only layout
Related
I am new in android app development I didn't declare anything for full screen mode still it asks in bottom of my application during runtime for full screen mode only for device with small screen like redmi 6A Here is output
Its just a demo app to ask for permission like call , contacts etc it works fine without crashing just i want to remove that option for full screen from bottom of the screen
would really be great full if anyone can guide
Thanks in advance
UPDATE
permission_layout.xml
<?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: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="com.android.dialer.PermissionActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
</LinearLayout>
</RelativeLayout>
So, I wanted to make a scroll-able worldmap with clickable countries. So when I found out there was a thing like VectorDrawables, I decided to give these a try.
Next thing I did was making a VectorDrawable xml file out of a SVG and tried to put it in my ImageView. While searching for some info, I found out that there were 101 ways to do this, and none of them worked for me...
The interesting thing is that, when I add "android:src="#raw/worldmap" in the ImageView in my activity.xml, the map shows up in the preview, but whenever I try to run the app, it crashes.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="#+id/activity_show_hint"
android:layout_width="match_parent"
android:layout_height="match_parent"
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="com.example.bert.myapplication.ShowHintActivity"
android:weightSum="1">
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:scaleType="center"
android:src="#raw/worldmap">
</ImageView>
</LinearLayout>
First, move your VectorDrawable to Drawable folder (not in raw). and then, add this line in your Gradle file :
defaultConfig{
vectorDrawables.useSupportLibrary = true
}
And finally, in your imageView, change to this;
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:scaleType="center"
app:srcCompat="#drawable/worldmap">
</ImageView>
I´m new in Java and Android Studio and tried to use a png in my test-application.
Since I own a AMD processor I have to use my real device (Galaxy S6) to run it. Strangely, the Image that I used shows up in Android Studio, plus it´s in the right size. Anyways, it´s not showing up on my device, theres only the white background.
Code: (content.main.xml)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.chris.startbildschirm.MainActivity"
tools:showIn="#layout/activity_main">
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:id="#+id/imageView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="#drawable/logo"/>
</RelativeLayout>
I was following this tutorial on how to get adMob on your app Here and
In my xml layout file for my activity I am getting a rendering problem:
A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout.
- <fragment xetron.cosmicclicker.MyActivity$AdFragment ...> (Pick Layout...)
- <fragment xetron.cosmicclicker.MyActivity$AdFragment ...> (Pick Layout...)
Do not warn about <fragment> tags in this session
Xml layout file for activity below
<LinearLayout 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="8dp"
android:orientation="vertical"
android:paddingBottom="6dp"
android:gravity="center|top"
android:background="#drawable/background"
tools:context=".MyActivity">
<fragment
android:name="xetron.cosmicclicker.MyActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/adFragment" />
<fragment
android:id="#+id/adFragment"
android:name="xetron.cosmicclicker.MyActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</LinearLayout>
What have I done wrong and how do i fix this?
In your fragments try putting this:
tools:layout="#layout/my_fragment_view"
where my_fragment_view is the layout you want to be loaded into the fragment. This is for the viewer only. I think the graphical view is giving you a tip so it can render more smoothly. tools attribute is for editor only. does not work at run time.
<fragment
android:name="xetron.cosmicclicker.MyActivity$AdFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/my_fragment_view"
android:layout_above="#+id/adFragment" />
When the app is loading, instead of a proper splash screen it just shows, the best way to describe it, when you go to install an app from the Play store, the black screen with the icon in the top left corner and some text, that's all it shows when launching my app...
I narrowed it down to activity_game.xml as when looking in the Graphical Layout of that file, it just shows a boring black screen with text.
How would I change this to incorporate a full screen image on splash instead?
Let's say for example, the image is called 'loading.png'
Content of activity_game.xml is below;
<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: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=".GameActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
--- Edit -
Thanks Rod, works to the point I now get a black screen on launch, I copied loading.png into the drawable folder and use the code like this;
<?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=".GameActivity" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/loading"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
</RelativeLayout>
Not sure why it is not loading the image?
First you need to make your activity full screen by setting the theme to no title bar into your activity tag of the manifest and add this:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Dont add padding to the RelativeLayout to avoid the black screen border, instead of TextView use the ImageView to create an image to the layout.
sample:
<?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=".GameActivity" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="your_drawable_image"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
</RelativeLayout>