Rendering problems in xml for admob - java

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" />

Related

Tab background is not there in programmatically

How to set the tab background color dynamically? I had tried to get the app:tabBackground="#drawable/tab_background" in the java code but I can't find please help me out friends I am using design library by google I had tried the custom view in the tab layout it worked but the gap is coming in between the tabs
My code
icon_tabs.addTab(icon_tabs.newTab().setCustomView(R.layout.first_tab), true);
icon_tabs.addTab(icon_tabs.newTab().setCustomView(R.layout.second_tab));
icon_tabs.addTab(icon_tabs.newTab().setCustomView(R.layout.third_tab));
icon_tabs.addTab(icon_tabs.newTab().setCustomView(R.layout.fourth_tab));
icon_tabs.addTab(icon_tabs.newTab().setCustomView(R.layout.five_tab));
My Layout for custom tab
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:orientation="vertical">
<FrameLayout
android:id="#+id/first_ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/first_tab_drawable">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:src="#drawable/love_home" />
</FrameLayout>
</FrameLayout>

Use RelativeLayout outside CoordinatorView

I have a CoordinatorLayout, in where a RecyclerView displays some CardViews, defined in an other layout. Under this scrollable view, i am trying to add a RelativeLayout, which inherits fields for text input, buttons for sending it, etc.
The problem: CoordinatorLayout seems to block the whole screen, although i told to wrap contents height. Nevertheless, RelativeLayout is added (tested it by setting Coordinator-height = 50dp), but off-screen. What is wrong here?
PS: I know how to solve it with android:layout_weight=xx. But thats not what i want to achieve, because it blocks my EditText to expand, if bigger texts are entered.
<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.support.design.widget.CoordinatorLayout
android:id="#+id/data_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="#+id/delete_data_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#id/data_coordinator_layout">
<EditText/>
<Button/>
<Button/>
<Button/>
</RelativeLayout>
</RelativeLayout>
It's actually pretty simple. You need to align your Relative Layout (delete_data_layout) to bottom of your parent. Then you make the Coordinator layout above the Relative Layout. This causes, that Coordinator layout will always stay above the Relative Layout - even when the Edittext expands.
Here's the XML.
<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.support.design.widget.CoordinatorLayout
android:id="#+id/data_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/delete_data_layout"> <---- Change here
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:id="#+id/delete_data_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"> <---- Change here
<EditText/>
<Button/>
<Button/>
<Button/>
</RelativeLayout>
</RelativeLayout>

What can i use instead of a Sliding drawer

im making a launcher app. in the tutorial it uses a Sliding Drawer which deprecated in Api 17. what could i use instead of this? i tried using the Slideup Panel from one of the posts on here link Below to the gitHub below
gitHubLinkhttps://github.com/umano/AndroidSlidingUpPanel
. but it wont allow me to use it in the way i want. i want the apps to appear in the drawer not in the main content. for some reason the second view only allows me to create a Text view which is for the handle to slide it up. any advice on what other methods i could implment to do the same job. it must slide up from the bottom. thanks for all the help
Ok guys Sussed it. Using The GitHub I posted in the question. what it did is because im aloud as many layouts as i like but only 2 children. i used a relative layout as my first layout with a gridView for my homescreen apps inside and closed it off. then i used anther Relative Layout Below with a textview inside then another Relative layout set with 80dp Padding at the top (the Size of my Text Handle) inside this one i had another gridview for my apps and closed it all off.
the Xml for it looks like this
<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"
android:id="#+id/Mainlayout"
>
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoPanelHeight="80sp"
sothree:umanoShadowHeight="4dp"
sothree:umanoDragView ="#+id/dragView"
sothree:umanoScrollableView="#+id/list"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/content1"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="50dp"
android:horizontalSpacing="50dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:clickable="true"
>
</GridView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/handle"
android:text="b"
android:textSize="80sp"
android:textColor="#17ff1c"
android:gravity="center|top"
android:clickable="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="80sp"
android:id="#+id/dragView"
android:clickable="true"
android:focusable="false">
>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="80sp"
android:id="#+id/content"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="50dp"
android:horizontalSpacing="50dp"
android:stretchMode="columnWidth"
android:gravity="center"
>
</GridView>
</RelativeLayout>
</RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</RelativeLayout>

Having trouble with the umano android slidinguppanel 2 views as sliding child

I am using this library from umanoAndroidSlidingUpPanel and it works fine theres just a problem I cant fix.
the main child is a mapview (static main view) that is working fine and the second child (the slidinguppanel) is a responsive html file in a webview and an imageview.
the problem is that when I swipe up to slide the panel i cant scroll the html file inside the webview.
the library states that I can make a single view draggable so that I can scroll the other but i really dont know how to do it help would be really appreciated.
heres my xml file
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="50dp"
sothree:shadowHeight="4dp">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/llayout"
android:orientation="vertical"
android:layout_height="match_parent" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity ="center_horizontal"
android:src="#drawable/divider">
</ImageView>
<WebView
android:layout_width="match_parent"
android:id="#+id/desc"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="7dp"/>
</LinearLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
I fixed it I just had to call the library method for setting the dragview and set only the imageview as draggable so the webview would scroll normally,
heres how I did it:
ImageView image=(ImageView)findViewById(R.id.divideri); //Layout to slide
SlidingUpPanelLayout layout = (SlidingUpPanelLayout)
findViewById(R.id.sliding_layout);
layout.setDragView(image);
Over and out ...

Android splash screen not appearing correctly

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>

Categories