android action bar overlay issue for Up button - android

I have been following the tutorial #
Add Up Button for Low-level Activities for a display_message_activity (I also set the action bar as transparent), and then tried to Specify Layout Top-margin using ?attr/actionBarSize, but the action bar ("My Message") seems covers the entire message ("Hello World") as follows
So I wonder how to solve the issue? The following is activity_display_message.xml in layout:
<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"
tools:context=".DisplayMessageActivity"
android:paddingTop="?attr/actionBarSize" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
cheers

Related

Image with transparent background start to have one in android studio

I'm trying to add an image with transparent background in android studio to a new empty project, but when I add it, it keeps giving me the transparent background as a background
Here's the image I'm trying to add
Here's what keeps happening
I tried many other images but the same thing keeps happening and I looked online but all I found was how to make the image itself transparent or semi-transparent but not the background
Here's the code in the xml file if it helps
<?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:id="#+id/activity_main"
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.ahmad.connectfour.MainActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
app:srcCompat="#drawable/eye"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
the java file is not edited at all
use this eye icon:
visit the link for more icons: https://material.io/resources/icons/?icon=check_circle_outline&style=baseline

How to remove space between app activity and navigation bar?

Screenshot was taken on Xiamoni Redmi Note5
In the emulator, this problem has not happened.
please help me.
Change your layout as follows:
<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=".CatalogActivity" >
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
// etc rest if the layout is the same

show grey lines / separator lines in an empty listView

I have a very simple listview, but now it shoes all empty when open it, I wanna user see the light grey lines in this empty list view to let them know this is something will list, Is there any way to show the lines when the listview still empty please?
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
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.anna.DiscoverActivity">
<android.support.v7.widget.SearchView
android:id="#+id/searchview"
app:queryHint="Search HoodMark"
android:background="#color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:layout_below="#id/searchview"
android:id="#+id/discover_list"
android:divider="#color/colorAccent"
android:dividerHeight="4px"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</RelativeLayout>`
Yes there is. Create an emptyView, design it as you like then supply it to the your adapter. Like this:
//inflate your empty view
View emptyView=getLayoutInflater().inflate(R.layout.emptyViewLayout,null,false);
//set to your listView
listView.setEmptyView(emptyView);

Where the right place to set layout in android?

I have 2 files in the res.
Activity_main.xml is
<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.test2.MainActivity"
tools:ignore="MergeRootFrame" />
fragment_main.xml is
<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.example.test2.MainActivity$PlaceholderFragment" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
I plan to change the layout where I problem in this current layout when I drag and drop all item just overlap on each other how to make a nice form type layout? What adjustment and which file must I adjust?
It sounds like you are using the Eclipse GUI tools to create your layout. I strongly suggest that you read about Android Layouts. If you want, you can edit the XML layout text directly or at the very least this will help you understand the properties you can set for your controls to get the exact look that you want.

Android Drawer Layout with main activity

was trying the drawer layout example mentioned in here
After trying this out, I added a few elements, like a button, to the main layout. This is what I did :
<?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" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="openTestButtonActivity"
android:text="#string/testing" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
.
.
.
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Now, the drawer works good, but I am not able to activate my button. Is there anything in the ordering of layouts that I am doing wrong ?
Yes, layout order is wrong. In relativeLayout views are ordered like are added in code. So if you add button first and then you add drawerLayout, drawerLayout overlays button. So you should add DrawerLayout first and then Button.

Categories

Resources