I am new in Android, so please help me.
In onDraw method I draw a lot of things, which I would like to have as a background. And when I click in the corner, I would like to have listview (with SeekBars, buttons, etc) and everything which i drow before as a background. This background doesn't have to scroll when the listview is scrolling. How to create and set such listview?
My .xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.project.MyView
android:id="#+id/main_view"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
Make your custom view as background of whole screen . You can do this by making the root view as your custom view .Then calculate the touch on corner and make your child view i.e. list view visible .
Related
i have create a custom view class, this class contains three TextViews. I am just using this custom view in on of my Fragment layout. My layout is like below
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.abc.views.HeaderView
android:id="#+id/headerView"
android:visibility="visible"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</com.rfs.app.views.HeaderView>
<ScrollView
android:id="#+id/widget54"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/footerView"
android:layout_below="#+id/headerView" >
--------------------------------------
--------------------------------------
</ScrollView>
</RelativeLayout>
The problem is, HeaderView child's updating(change text/color) when i click on button in my fragment. these changes are not reflecting instantly.
all child's are textviews in HeaderView class.
Is there any way to re-fresh or re-create this custom view?
Obviously your custom view doesn't invalidates itself correctly. Please make sure you call invalidate or postInvalidate if doing work in background thread, whenever you want your custom view to call onDraw. You can share your custom view code so that we can point out the issue here.
I'm trying to create list item with blue overlay on top of the item. The blue overlay only appear when user touch on the item. So I'm placing view with background drawable to cover the whole item.
The problem now is that this View never get drawn at all. I could switch the background to simple color and it would not appear. If I change it to TextView instead, the text will be shown but not covered the whole item. What am I doing wrong?
The layout get updated for sure, if I change color of any TextView it would apply that change accordingly.
Here's a layout for the list item.
<?xml version="1.0" encoding="utf-8"?>
..<!-- other stuff -->..
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#drawable/item_overlay"
android:duplicateParentState="true"
android:visibility="visible"
/>
1) You can list selector, along with option drawSelectoronTop
<ListView android:listSelector="#drawable/list_selector"
android:drawSelectorOnTop="true">
</ListView>
setting drawSelectoronTop true will cause the drawable to draw over the list item(ForeGround)
2) If list selector can't be applied to your particular design, you can use FrameLayout as the list item's parentView, with foreground property
android:foreground="#drawable/list_selector"
for more about this you can refer the post Draw selector on top - for a basic linear layout?
I have an Activity with a ListView.I want to set as a background a simple white picture with a logo in the right lower corner.My problem is that when i set as background my picture it kinda 'sits' in front of my listView.Making the textViews seem faded.How can i effectively add a background without these side effects?Thank you for your time.
EDIT:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/bg">
<dragNDropAdapter.DragNDropListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</dragNDropAdapter.DragNDropListView>
</RelativeLayout>
Put imageview & listview in relative layout.
Set attribute for your image where you want to place it and for list as well.
I am struggling with making one view's background transparent so that any areas on top view that are not drawn actually reveals the bottom view.
I have read several threads here about this, but whatever I try the top view is drawn in black.
Both bottom view and top view are inherited from the View base class and onDraw() is overridden and this is my layout.xml:
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<com.domain.myapp.MyBottomView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mybottomview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bottom_image"/>
<com.domain.myapp.MyTopView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mytopview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"/>
</merge>
Anyone got any suggestions for me I would be extremely greatful!
Regards
/Dee
Try this.
android:background="#android:color/transparent"
A resource is available here : http://android-developers.blogspot.in/2009/01/why-is-my-list-black-android.html
On my screen I have a list view and a button. my list has like 8 item. I would like my screen to scroll if both these items does not fit in. I don't want my list to have scroll but the complete layout including both list & button. If I use the below layout it only shows on item inside the list and I have to scroll within the list to go to next item.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#android:id/list"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:background="#drawable/round_background" />
<Button android:text="Search" android:id="#+id/carSearchButton"
android:layout_gravity="center_horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
You can't put a ListView inside a ScrollView. Of GridView, or whatever View that handles scrolling on the same axis as the ScrollView does. That way the framework wouldn't know which View should handle the scrolling event. This layout won't produce an error when you compile it, but it won't work properly.
What you should do here: dump the outer ScrollView, you don't need it. Only use a ListView, and add the button to the ListView, using .addFooter(), that's the easiest way. This way your button'll appear as a list element, but you don't have to mess around with a custom adapter.
Scythe kind of answers my question but I wanted more then one one control below the list also on another screen I wanted 2 lists. So in order to have the scroll bar working with list view I had to fix the height of the list.