Android view behind another with swiping motion - android

to explain the situation :
-i have a listview filled with multiple rows, now i want to take any row and swipe left or right;
either way i need to show another view behind the current row as i swipe( kind of the sliding menu with the action bar, although i dont think i can use that in my case)
when the user swipes left for example the new view can have an offset, (or doesnt), so it may or may not cover the whole row, any suggestions ?
thanks a lot
random code()
<ListView
android:id="#+id/lvWatchlists"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/relativeLayout1"
android:layout_below="#+id/header_l" >
</ListView>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#004c98" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/donnees" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/imageView1"
android:text="#string/differe"
android:textColor="#color/title_selected"
android:textSize="#dimen/footer_text" />
<TextView
android:id="#+id/maj2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="00/00/00 à 00:00:00"
android:textColor="#color/title_selected"
android:textSize="#dimen/footer_text" />
<TextView
android:id="#+id/maj1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/maj2"
android:text="#string/maj_le"
android:textColor="#color/title_selected"
android:textSize="#dimen/footer_text" />
</RelativeLayout>

use swipeable list view library from here
https://github.com/47deg/android-swipelistview
or check this open sourced program for the same feature by roman nurik
https://code.google.com/p/dashclock/source/browse/main/src/main/java/com/google/android/apps/dashclock/ui/SwipeDismissListViewTouchListener.java

It depends what you or doing on by swiping the row view, deleting it or something else

Related

image with four clickable areas

Here is what I am trying to do. I am creating a drag and drop controller. Users are able to move the controls where they want on the screen to save it. I have everything else done, except this. I have thought of a couple different ideas to get this to work, but most of them do not work so well with the drag and drop feature.
I have created an XML file.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="50dp"
android:layout_height="40dp"
android:text=""
android:id="#+id/dpad_up"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:visibility="invisible"/>
<Button
android:layout_width="50dp"
android:layout_height="40dp"
android:text=""
android:id="#+id/dpad_down"
android:layout_below="#+id/dpad_up"
android:layout_centerHorizontal="true"
android:visibility="invisible"/>
<Button
android:layout_width="50dp"
android:layout_height="40dp"
android:text=""
android:id="#+id/dpad_left"
android:layout_alignTop="#+id/dpad_right"
android:layout_toStartOf="#+id/dpad_up"
android:visibility="invisible"/>
<Button
android:layout_width="50dp"
android:layout_height="40dp"
android:text=""
android:id="#+id/dpad_right"
android:layout_alignParentTop="true"
android:layout_toEndOf="#+id/dpad_up"
android:layout_marginTop="22dp"
android:visibility="invisible"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/d_pad"
android:background="#drawable/d_pad"
android:layout_alignParentTop="true"
android:layout_alignBottom="#+id/dpad_down"
android:layout_alignStart="#+id/dpad_left"
android:layout_alignEnd="#+id/dpad_right" />
</RelativeLayout>
I was thinking of using that XML bring into my activity and do a drag and drop, but I am not sure how I could do that. Any ideas or help would be great. I just need to be able to perform a drag and drop and have each of the directions buttons register when pressed to perform the action.
Invisible views are not touchable.
Just change Button into View or Space, and let it visible.

i have some views within a scrollview.i want to change the title of the actionbar while scrolling up

i have some views within a scrollview in a xml file.i want to change the title of the action bar while scrolling up.anyaone please help me how to do that..
this is my xml file
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="email"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="address"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</ScrollView>
You want to observe the scrollview's scrolling? For whatever reason you can't do this via the Android SDK for scrollviews (you can for listviews however). As a result there are whole libraries!
https://github.com/ksoichiro/Android-ObservableScrollView
Or you can easily implement something similar fairly simpply such as
https://stackoverflow.com/a/3952629/3865761 if it meets your needs. Standing on the shoulders of stack overflow giant's as it were.
Once you can detect the scrolling, simply have methods such as onScrollUp() that increases the font size for your textviews, and resetTextViewState() which sets it back to its default called from the onScrollingChanged() callback you implement.

ListView highlighter doesn't work over certain png's

I've a layout for top (and bottom) elements which look like this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/topbgprayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/prayer_top" />
<ImageView
android:id="#+id/topleftpatchprayer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/topbgprayer"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/leftbgprayer"
android:src="#drawable/prayer_top_left_patch" />
<ImageView
android:id="#+id/toprightpatchprayer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/prayer_top_right_patch" />
<ImageView
android:id="#+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:src="#drawable/play_fill_free_download" />
<ImageView
android:id="#+id/spare_play"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:src="#drawable/spare_play" />
<TextView
android:id="#+id/tvDescr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/ivImage"
android:lineSpacingMultiplier="1.05"
android:layout_marginRight="30sp"
android:text="Молитвы Утренние"
android:textSize="18sp" />
<TextView
android:id="#+id/tvBottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="center_horizontal"
android:paddingBottom="6dp"
android:layout_toLeftOf="#+id/tvDescr"
android:text="12 МБ"
android:textSize="10sp"
android:typeface="sans" />
</RelativeLayout>
so, main idea is that on top elements there is a tiled image on top and two patches to smooth the corners.
For some reason, highlighter on a ListView doesn't highlight over that images, but highlight others. If I try to delete some of theese images - it highlights area where they were deleted. How can I fix that?
The highlight by default is drawn behind the list item view, therefore you see in behind the text and behind the triangle image (probably because the triangle image is transparent around the triangle), the other image is opaque so it hides the highlight.
What you should do is make a semi-transparent highlighter and draw it on top of the view. Check out this question for information on how to draw in on top: How to highlight ListView item on touch?
Alternatively you can disable the highlight completely, and add a hidden view on top of all the list item and use onTouchListener() to show it only when there is an ACTION_DOWN and hide it again when there is an ACTION_UP.

How to create custom image view like custom list view?

I want to make one application which contains multiple choice question. Each question has three option. I want to show that option with one background image. And also want to change the color of that image randomly for each question. How can i do that?
It is possible to create list view by putting differnt background image for each row?
Result.xml
<LinearLayout
android:id="#+id/linearlayoutans"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:layout_toLeftOf="#+id/chrono"
android:orientation="horizontal" >
<TextView
android:id="#+id/txt_ans_true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:textColor="#000000" />
<TextView
android:id="#+id/txt_ans_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:textColor="#000000" />
<TextView
android:id="#+id/txt_ans_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:textColor="#000000" />
</LinearLayout>
It is possible to create list view by putting differnt background
image for each row?
Yes. Take a look at articles on the internet that back a listview with a custom adapter and a custom view. This is done from the getView() method and there is no shortage of examples / tutorials out there.

Android ListView Item - Right to Left Animation Menu

In my android application I want the ListView items to move from right to left and show extra options for that row. I don't know how to ask my question so I want to show you the pictures that I took. How can I do that or what it is called ?
This is the first state.
This is the secondstate (after click on the "PLUS" icon on the right side).
This was the final state which shows the extra choices
Is it possible that a ViewPager could be used?
I'm not sure that it would work for only a small part of the screen, but it could be worth a try... :)
More info can be found here (d.android.com)
UPDATE : Thanks to "ToVine", I researched for View Transitions. ViewFlipper suits for what I mentioned belove :). This is my custom listview row's xml.
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="buttonClickHandler" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:onClick="buttonClickHandler"
android:src="#android:drawable/btn_star_big_on" />
</LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="TextView2" />
</ViewFlipper>

Categories

Resources