Hi I cant figure for the life of me to change the background of this to white.
CODE:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
>
<ExpandableListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
>
</ExpandableListView>
</LinearLayout>
Make the black here white
Probably going have to change the font color to black.
Can you post a screenshot of how it looks now? And perhaps a quick description of how you'd like it to look?
Does it look like you want it to but mess up when you go to scroll the list?
Check out this page for some useful info on using listviews with custom backgrounds: http://developer.android.com/resources/articles/listview-backgrounds.html
try setting the cacheColorHint:"00000000"
Related
How can I completely change the color of my preferenceActivity background? Please see my screenshot. On a tablet there is sort of a white border around the window background and listview background. I can't figure out how to change its color/drawable. I just need to make it transparent.
This is how I achieved the screenshot. This code is placed in the onCreate of the PreferenceActivity.
this.getListView().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));
this.getWindow().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));
Hopefully I will not have to get into any styles and I can just access it in code for simplicity's sake.
Okay so you need to set the layout to a custom one. The only requirement for the custom layout is to have a list view with id of android:id/list
Like this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:background="#drawable/DRAWABLE HERE"
>
<ListView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#android:id/list"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
/>
</LinearLayout>
Than in your onCreate of the PrefActivity:
this.setContentView(R.layout.pref_act);
I don't know if it's the right way to do this but I hope you'll be able to help me.
I'm using a ListActivity to display content from RSS feed. While the content is loading I want to display a pending view. I'm using the EndlessAdapter from that website https://github.com/commonsguy/cwac-endless. It provides a way to display a pending view but the first time it loads data it's a tiny row in an empty list so it's not very sexy.
I'm actually trying to fix this up with this method :
A custom layout for my ListActivity where there is a pending view that I can hide or show for the first loading. The XML code of the layout is like this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"/>
<include
android:id="#+id/progressBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout="#layout/loading_anim">
</include>
</LinearLayout>
The first time I load data I set the list visibility to gone with this line :
listView.setVisibility(View.GONE);
It's almost working but the included layout doesn't fill the entire screen and right know I don't know how to fix this in a proper way.
Hope someone will be able to help me, thank's!
UPDATE :
I tried to set the contentview with only the loading layout (see XML below) and I got the same result (see http://imageshack.us/photo/my-images/594/loadingwf.png/) :
this.setContentView(R.layout.loading_anim);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:padding="5dp" >
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="#string/loading" />
</LinearLayout>
So I'm wondering if maybe it's because of the tabs... Can anybody help me ? Thank's
UPDATE 2
I found a solution, it had nothing to do with the neverending adapter. See The content of my tabs doesn't fill the whole space
In your ListView, try this:
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:cacheColorHint="#FFFFFF"/>
What I did was set layout_height to wrap_content. Should fill your entire screen now.
The following code is almost the same thing I want to achieve.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bg">
<ListView android:layout_height="wrap_content" android:id="#+id/levelList" android:layout_width="match_parent" android:layout_alignParentLeft="true"></ListView>
</RelativeLayout>
I want to setup a background image for the whole ListView. The problem of this code is that background image blinks or disappears on scrolling.
I use sdk 2.2 and an emulator to run the program.
You'll want to set android:cacheColorHint="#00000000" on your ListView. This will set the cacheColorHint to transparent (notice the extra 2 0's after #000000) and fix your problem. Alternatively you can set the cacheColorHint to #android:color/transparent.
You should read this page on ListView backgrounds.
I am trying to change the background of whole screen to white. I doing it by adding by android:background="#ffffff" attribute to linerlayout. but it is not working, i dont know what i am missing ?
http://developer.android.com/reference/android/widget/LinearLayout.html
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="10dip"
android:layout_width="fill_parent" android:layout_height="wrap_content"
**android:background="#ffffff"** >
I also tried to this programtically , something like this
setContentView(R.layout.main);
LinearLayout linLay = (LinearLayout) findViewById(R.layout.main);
linLay.setBackgroundColor(Color.WHITE);
but application throws error
Are you please able to post the complete code necessary to replicate your problem?
This works fine for me:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
android:layout_height="fill_parent"
also setBackGroundColor(int) takes a #color resource , not a color integer. you declare them in values/colors.xml
I like the Android market apps design, very bright and catchy layout. How it has been done? i tried to put such green semi-circle bar on top with transparency on circle, but my listview is not going behind, where in market apps listview scrolls behind the green bar.
Many thanks in advance.
Rgds
Balaji
I don't know exactly you want this or not but it may help you.
xml layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.v7.widget.Toolbar
android:id="#+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/transparent">
</android.support.v7.widget.Toolbar>
in Manifest file
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.NoActionBar" >
Color.xml
<color name="transparent">#64000000</color>
As a way I can suggest something like this:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<View
android:id="#+id/top_place_holder"
android:layout_width="fill_parent"
android:layout_height="100dip"
/>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/top_place_holder"
/>
<View
android:id="#+id/your_top_panel"
android:layout_width="fill_parent"
android:layout_height="130dip"
androis:background="#drawable/your_transparent_semi_circle_here"
/>
So it goes like this:
#id/top_place_holder is used to take some space and push the ListView down a bit, so it won't take the whole screen.
#id/your_top_panel is a top panel (the one that will hold your transparent semi circle stuff). It must be a little bigger (in height) than place_holder since it'll cover it and a bit of it will be hovering over the list view, so it would look, like the list view is below.
To not make the actual list elements hide below the top panel - set a header view for your ListView (ListView.addHeaderView()) that will take some space and won't let the first row of data to hide below the top panel.
That above is, of course, a hack way. The best way is to layout components yourself programmatically, so you won't be needing any place_holders and your sizes wouldn't be so hardcoded.