In my project, I have a list of playing videos, which is built using RecyclerView. When the user clicks to play, the sharing area below the video will have some share icons added (here with LayoutAnimation added), The entire share pannel will stretch; Now The problem is that when user play the video, and quickly or repeatedly slide the list back and forth, the video list will appear disorderly, the video below the screen will be staggered coverage, affecting the user experience, Does someone have encountered this issue, And what is the right way to add item animtion in recyclerView?
code in adpter:
private void animateExitBottomViews(final VideoClipsPlayViewHolder holder, boolean isFollow) {
if (null != holder) {
if (isFollow) {
holder.ll_share.setVisibility(View.GONE);
holder.ll_share_abord.setVisibility(View.GONE);
holder.imgMoreShare.setVisibility(View.GONE);
holder.imgAllShare.setVisibility(View.VISIBLE);
} else {
holder.imgHead.bringToFront();
holder.imgAllShare.setVisibility(View.VISIBLE);
holder.imgMoreShare.setVisibility(View.GONE);
holder.ll_share.setVisibility(View.GONE);
holder.ll_share_abord.setVisibility(View.GONE);
hideFocusButtonWhenFocused(holder);
}
}
}
xml file of item layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mgtv="http://schemas.android.com/apk/res-auto"
android:id="#+id/rl_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#color/skin_color_content_bg_primary">
<RelativeLayout
android:id="#+id/rl_player"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_202"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<RelativeLayout
android:id="#+id/rl_play"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/view_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
mgtv:fadeDuration="100"
mgtv:placeholderImage="#drawable/bg_common_image_holder" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/icon_common_video_play" />
<TextView
android:id="#+id/tv_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="#dimen/dp_5"
android:layout_marginRight="#dimen/dp_5"
android:background="#drawable/item_vod_landscape_image_text_item_desc_selector"
android:gravity="center"
android:minHeight="#dimen/dp_16"
android:paddingLeft="#dimen/dp_3"
android:paddingRight="#dimen/dp_3"
android:textColor="#color/color_FFFFFF"
android:textSize="#dimen/font_20" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/fl_player_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
<TextView
android:id="#+id/txt_video_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/rl_player"
android:ellipsize="end"
android:maxLines="2"
android:paddingLeft="#dimen/dp_10"
android:paddingRight="#dimen/dp_10"
android:paddingTop="#dimen/dp_10"
android:textColor="#color/skin_color_text_primary"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/frame_video_info"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_50"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/txt_video_title">
<com.mgtv.widget.CircleImageView
android:id="#+id/img_head"
android:layout_width="#dimen/dp_35"
android:layout_height="#dimen/dp_35"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/dp_10"
android:src="#drawable/ic_comment_avatar_default"
mgtv:civ_border_color="#color/color_000000_10"
mgtv:civ_border_width="1px" />
<com.hunantv.imgo.widget.RoundRectCheckButton
android:id="#+id/btn_focus"
style="#style/FollowCheckButtonStyle"
android:layout_width="#dimen/dp_60"
android:layout_height="#dimen/dp_26"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/dp_5"
android:layout_toRightOf="#id/img_head"
android:visibility="gone" />
<TextView
android:id="#+id/txt_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/dp_5"
android:layout_toRightOf="#id/img_head"
android:ellipsize="end"
android:maxEms="8"
android:maxLines="1"
android:textColor="#color/color_888888" />
<LinearLayout
android:id="#+id/ll_share_icon"
android:layout_width="wrap_content"
android:layout_height="#dimen/dp_40"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
**android:animateLayoutChanges="true"**
android:gravity="center_vertical">
<TextView
android:id="#+id/txt_comment_reply"
android:layout_width="wrap_content"
android:layout_height="#dimen/dp_32"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp_3"
android:layout_toLeftOf="#+id/txt_praise"
android:drawableLeft="#drawable/videoclips_comment_reply"
android:drawablePadding="#dimen/dp_3"
android:gravity="center_vertical"
android:text="128"
android:textColor="#color/base_middle_gray"
android:textSize="#dimen/font_20" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/dp_5"
android:layout_toLeftOf="#+id/ll_share_more">
<TextView
android:id="#+id/txt_praise"
android:layout_width="wrap_content"
android:layout_height="#dimen/dp_32"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/dp_6"
android:drawableLeft="#drawable/ic_comment_up_default"
android:drawablePadding="#dimen/dp_3"
android:gravity="center_vertical"
android:text="235"
android:textColor="#color/base_middle_gray"
android:textSize="#dimen/font_20" />
<TextView
android:id="#+id/tvLikePlusOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/plus_one"
android:textColor="#color/color_F06000"
android:textSize="#dimen/font_24"
android:visibility="invisible" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:id="#+id/img_wechat_share"
android:layout_width="#dimen/dp_32"
android:layout_height="#dimen/dp_32"
android:layout_centerVertical="true"
android:scaleType="centerInside"
android:src="#drawable/videoclips_share_wechat" />
<ImageView
android:id="#+id/img_wechat_group_share"
android:layout_width="#dimen/dp_32"
android:layout_height="#dimen/dp_32"
android:layout_centerVertical="true"
android:scaleType="centerInside"
android:src="#drawable/videoclips_share_wechat_group" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_share_abord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:id="#+id/img_facebook_share"
android:layout_width="#dimen/dp_32"
android:layout_height="#dimen/dp_32"
android:layout_centerVertical="true"
android:scaleType="centerInside"
android:src="#drawable/videoclips_share_facebook" />
<ImageView
android:id="#+id/img_twitter_share"
android:layout_width="#dimen/dp_32"
android:layout_height="#dimen/dp_32"
android:layout_centerVertical="true"
android:scaleType="centerInside"
android:src="#drawable/videoclips_share_twitter" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_share_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="horizontal">
<ImageView
android:id="#+id/img_more_share"
android:layout_width="#dimen/dp_32"
android:layout_height="#dimen/dp_32"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp_10"
android:scaleType="centerInside"
android:src="#drawable/videoclips_share_more"
android:visibility="gone" />
<ImageView
android:id="#+id/img_all_share"
android:layout_width="#dimen/dp_32"
android:layout_height="#dimen/dp_32"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp_10"
android:scaleType="centerInside"
android:src="#drawable/videoclips_share_all"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<View
android:id="#+id/item_bottom_devider"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_8"
android:layout_alignParentBottom="true"
android:layout_below="#+id/frame_video_info"
android:background="#color/skin_color_divider" />
</RelativeLayout>
I just dynamically control the visiblity of the share icon, the animate behavior was call by LayoutAnimation, just wondering why the screen will be disorderly when the list is quickly swiped.
UI STUTTER WHEN FAST SCROLL LIST
NORMAL STATE OF SHARE PANEL
EXPAND STATE OF SHAE PANEL
finally,ValueAnimation save my day!
private ValueAnimator createShareAnimator(final View v, final int start, final int end) {
ValueAnimator animator = ValueAnimator.ofInt(start, end);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
#Override
public void onAnimationUpdate(ValueAnimator animator) {
Integer currentValue = (Integer) animator.getAnimatedValue();
ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
layoutParams.width = currentValue;
v.setLayoutParams(layoutParams);
}
});
return animator;
}
Related
I m developping webrtc android application, I used Relative layout to put in it two SurfaceViewRenderer elements one used for local stream view and other for remote stream.
here my layout xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_height="0dip"
android:layout_weight="0"
android:layout_width="match_parent"
android:id="#+id/video_layout"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical"
android:clickable="true"
android:focusable="false"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/glview_parent"
>
<org.webrtc.SurfaceViewRenderer
android:id="#+id/remoteview"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_above="#+id/localview"
/>
<org.webrtc.SurfaceViewRenderer
android:id="#+id/localview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
<TextView
android:id="#+id/messageTXT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:paddingTop="50dp"
android:paddingRight="50dp"
android:padding="10dp"
android:textSize="20sp"
android:background="#66000000"
android:textColor="#color/list_background"
android:visibility="gone"
/>
<Chronometer
android:id="#+id/chronoLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:paddingTop="50dp"
android:paddingRight="50dp"
android:padding="10dp"
android:textSize="20sp"
android:background="#66000000"
android:textColor="#color/list_background"
android:visibility="gone"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/buttons_layout"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:padding="5dp"
android:background="#66000000"
>
<ImageButton
android:id="#+id/speaker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/speaker_on"
android:background="#android:color/transparent"
android:paddingRight="10dp"
/>
<ImageView
android:id="#+id/ok01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_ok"
android:background="#android:color/transparent"
android:visibility="gone"
android:paddingRight="10dp"
/>
<ImageView
android:id="#+id/no01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/ic_no"
android:visibility="gone"
android:paddingRight="10dp"
/>
<ImageButton
android:id="#+id/micro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/mico_on"
/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
on call progressing i initialised local and remote SurfaceViewRenderer programetically like this .
public void initVideos() {
remotevideoview.setVisibility(View.GONE);
RelativeLayout.LayoutParams local,remote;
remote=new RelativeLayout.LayoutParams(0,0);
remotevideoview.setLayoutParams(remote);
local = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
localvideoView.setLayoutParams(local);
}
When call is establiched and onaddstream event fire I update layout like this :
public void updateVideos(){
RelativeLayout.LayoutParams remote = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
int w=video_layout.getWidth();
int h=video_layout.getHeight();
RelativeLayout.LayoutParams local = new RelativeLayout.LayoutParams(w/3, h/3); // or wrap_content
local.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
local.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
local.setMargins(2, 2, 2, 2);
glview_parent.updateViewLayout(remotevideoview, remote);
glview_parent.updateViewLayout(localvideoView, local);
remotevideoview.setVisibility(View.VISIBLE);
localvideoView.bringToFront();
glview_parent.invalidate();
localvideoView.invalidate();
remotevideoview.invalidate();
}
All is ok until now. but when i click onbackpressed and exit call activity. and after that I like to show local and remote videos again when user enter on call activity. I call updateVideos() and i render local and remote stream but I can not see localvideoView. I see only remotevideoview that match all parent width and height. localvideoview is always bring to back . I try all possible codes but I can not see localview. I use localvideoView.bringToFront(); but without success.
In My android app, I used popup window.
There is one issue regarding popup window.
In bigger device (height or width) It will show clearly and automatically set margin left or right.
In smaller device like nexus one , Popup window stick with device not set margin left or right.
Or another issue is that In lollipop or marshmallow there is one button look like floating button. You can view in screen shot which I attached below.
That button look good in marshmallow or higher version.
But in kitkat there is only look like a simple arrow how to resolved it.
Here i specified My popup window source code or screenshots of kitkat device UI and Marshmallow UI.
please any one let me know how to resolved it. In advance, Thank you for your support.
raw_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/demo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorWhite"
android:orientation="horizontal"
android:padding="16dp">
<TextView
android:id="#+id/txtMainHeading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginLeft="10dp"
android:text="#string/headertext"
android:textColor="#color/colorBlack"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/txtText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="10dp"
android:text="#string/popupsubtext"
android:textColor="#color/colorBlack" />
<View
android:id="#+id/viewMain"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="#+id/txtText"
android:background="#color/bg_border" />
<View
android:id="#+id/view"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/LayoutDetail"
android:layout_marginLeft="95dp"
android:layout_marginRight="10dp"
android:background="#color/bg_border" />
<LinearLayout
android:id="#+id/LayoutDetail1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/view"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtLastNameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="#string/puplastname"
android:textColor="#color/colorBlack"
android:textSize="15sp" />
<TextView
android:id="#+id/txtLastName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:focusableInTouchMode="true"
android:text="#string/txtLastnametext"
android:textColor="#color/button_text_dialog"
android:textSize="16sp" />
</LinearLayout>
<View
android:id="#+id/view1"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/LayoutDetail1"
android:layout_marginLeft="95dp"
android:layout_marginRight="10dp"
android:background="#color/bg_border" />
<LinearLayout
android:id="#+id/LayoutDetail2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/view1"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtEmailText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="#string/pupEmail"
android:textColor="#color/colorBlack"
android:textSize="15sp" />
<TextView
android:id="#+id/txtEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="#string/txtemailtext"
android:textColor="#color/button_text_dialog"
android:textSize="16sp" />
</LinearLayout>
<View
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_below="#+id/LayoutDetail2"
android:layout_marginBottom="10dp"
android:layout_marginLeft="70dp"
android:layout_marginRight="10dp"
android:background="#color/bg_border" />
<ImageView
android:id="#+id/btnNext"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/LayoutDetail2"
android:layout_margin="#dimen/fab_margin"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="14dp"
android:background="#drawable/shape_oval"
android:elevation="2dp"
android:scaleType="center"
android:src="#drawable/ic_icon_right_1" />
<LinearLayout
android:id="#+id/LayoutDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtText"
android:layout_gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtFirstNameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:text="#string/pupfirstname"
android:textColor="#color/colorBlack"
android:textSize="15sp" />
<TextView
android:id="#+id/txtFirstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:focusableInTouchMode="true"
android:text="#string/txtFirstnametext"
android:textColor="#color/button_text_dialog"
android:textSize="16sp" />
</LinearLayout>
Popupwindow.java
private Context mContext;
private Activity mActivity;
private android.widget.PopupWindow mPopupWindow;
private RelativeLayout mRelativeLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_countrycode);
mContext = getApplicationContext();
// Get the activity
mActivity = CountrycodeActivity.this;
// Get the widgets reference from XML layout
mRelativeLayout = (RelativeLayout) findViewById(R.id.mRelativeLayout);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
// Inflate the custom layout/view
View customView = inflater.inflate(R.layout.raw_layout, null);
mPopupWindow = new android.widget.PopupWindow(
customView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT
);
// mPopupWindow.setContentView(findViewById(R.id.activity_view_pager));
mPopupWindow.setAnimationStyle(R.style.PopupAnimation);
if (Build.VERSION.SDK_INT >= 21) {
mPopupWindow.setElevation(24f);
}
new Handler().postDelayed(new Runnable() {
public void run() {
mPopupWindow.showAtLocation(mRelativeLayout, Gravity.CENTER, 0, 0);
}
}, 100L);
}
#Override
protected void onStop() {
super.onStop();
mPopupWindow.dismiss();
}
Screenshots of UI
In marshmallow as well as bigger device nexus 5.1
In nexus one as well as kitkat device or smaller
android:layout_width="fill_parent"
set RelativeLayout width property fill_parent
Here is what I'm trying to do. I have 4 images and they are in one LinearLayout and that LinearLayout is child of RelativeLayout. I have successfully implemented onClickListener. Maybe my question is a little different, but everything is relevant.
I don't know how to extend image to full screen because images are in one LinearLayout which is inside that one RelativeLayout and maybe everything will be clear when I show you guys xml code.
I would like to make ImageView full screen on click and to be able to go back when I click back button. For that I would probably need to use onBackPressed
Images are at the bottom.
So here is the xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:background="#drawable/url"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:scrollbars="none" >
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Thumbnail Image -->
<com.dusandimitrijevic.modification.TouchImageView
android:id="#+id/thumbnail"
android:layout_width="140dp"
android:layout_height="220dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="8dp"
android:src="#drawable/ic_horor_filmovi_ikonica" />
<!-- Naslov Filma -->
<TextView
android:id="#+id/naslov"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="#7F0000"
android:textSize="#dimen/title_movie"
android:layout_toRightOf="#id/thumbnail"
android:layout_toEndOf="#+id/thumbnail" >
</TextView>
<!-- Godina izdanja Filma -->
<TextView
android:id="#+id/releaseYear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/naslov"
android:layout_alignStart="#+id/naslov"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="#+id/naslov"
android:layout_marginTop="3dp"
android:textColor="#color/dark_red" />
<ImageView
android:id="#+id/rating_star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/thumbnail"
android:layout_marginBottom="42dp"
android:layout_toRightOf="#+id/thumbnail"
android:layout_toEndOf="#+id/thumbnail"
android:src="#drawable/ic_actions_rating_icon" />
<Button
android:id="#+id/url_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/thumbnail"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_toRightOf="#+id/thumbnail"
android:layout_toEndOf="#+id/thumbnail"
style="#style/UrlDugme" />
<TextView
android:id="#+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/rating_star"
android:layout_alignTop="#+id/rating_star"
android:layout_toRightOf="#+id/rating_star"
android:layout_toEndOf="#+id/rating_star"
android:gravity="center"
android:textColor="#color/dark_red"
android:textSize="#dimen/rating" />
<!-- Opis Filma -->
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="#+id/thumbnail"
android:layout_marginTop="14dp"
android:background="#drawable/layout_round_rect_shape" >
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:layout_marginTop="16dp"
android:scrollbars="vertical"
android:textColor="#color/dark_red"
android:textSize="18sp" />
</RelativeLayout>
<!-- Opis Filma Zavrsetak -->
<!-- Glumci -->
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout1"
android:layout_marginTop="12dp"
android:background="#drawable/layout_round_rect_shape"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayoutActors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/Image1"
android:layout_width="40dp"
android:layout_height="140dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/ic_horor_filmovi_ikonica" />
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/Image2"
android:layout_width="40dp"
android:layout_height="140dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/ic_horor_filmovi_ikonica" />
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/Image3"
android:layout_width="40dp"
android:layout_height="140dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/ic_horor_filmovi_ikonica" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayoutActors"
android:orientation="horizontal" >
<TextView
android:id="#+id/ime1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Ime"
android:textColor="#7F0000"
android:textSize="16sp" />
<TextView
android:id="#+id/ime2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Ime"
android:textColor="#7F0000"
android:textSize="16sp" />
<TextView
android:id="#+id/ime3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Ime"
android:textColor="#7F0000"
android:textSize="16sp" />
</LinearLayout>
</RelativeLayout>
<!-- Glumci -->
<!-- IMAGES I WANT TO MAKE FULLSCREEN ON CLICK -->
<LinearLayout
android:layout_marginTop="12dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/layout_round_rect_shape"
android:id="#+id/linearLayoutImages"
android:layout_below="#+id/relativeLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.dusandimitrijevic.modification.TouchImageView
android:id="#+id/image1"
android:adjustViewBounds="true"
android:layout_weight="1"
android:layout_width="115dp"
android:layout_height="150dp"
android:src="#drawable/ic_horor_filmovi_ikonica" >
</com.dusandimitrijevic.modification.TouchImageView>
<com.dusandimitrijevic.modification.TouchImageView
android:id="#+id/image2"
android:adjustViewBounds="true"
android:layout_weight="1"
android:layout_width="115dp"
android:layout_height="150dp"
android:src="#drawable/ic_horor_filmovi_ikonica" >
</com.dusandimitrijevic.modification.TouchImageView>
<com.dusandimitrijevic.modification.TouchImageView
android:id="#+id/image3"
android:adjustViewBounds="true"
android:layout_weight="1"
android:layout_width="115dp"
android:layout_height="150dp"
android:src="#drawable/ic_horor_filmovi_ikonica" >
</com.dusandimitrijevic.modification.TouchImageView>
<com.dusandimitrijevic.modification.TouchImageView
android:id="#+id/image4"
android:adjustViewBounds="true"
android:layout_weight="1"
android:layout_width="115dp"
android:layout_height="150dp"
android:src="#drawable/ic_horor_filmovi_ikonica" >
</com.dusandimitrijevic.modification.TouchImageView>
</LinearLayout>
<!-- IMAGES I WANT TO MAKE FULLSCREEN ON CLICK -->
</RelativeLayout>
</ScrollView>
</RelativeLayout>
And here is onClickListener:
image1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 115, getResources().getDisplayMetrics());
int px1 = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 150, getResources().getDisplayMetrics());
LinearLayout.LayoutParams p = new LinearLayout.
LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
p.weight = 1;
if(isImageFitToScreen) {
image1.setMinimumWidth(px);
image1.setMinimumHeight(px1);
image1.setAdjustViewBounds(true);
isImageFitToScreen=false;
}else{
image1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
image1.setScaleType(ImageView.ScaleType.FIT_XY);
isImageFitToScreen=true;
}
}
});
To offer an alternative to Ben's answer and flesh out my earlier comment, one possibility is to create an ImageView in your xml that occupies the entire screen, with its visibility set to gone. On your button press, load the image into this ImageView, and on a back press set the visibility to gone again.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ScrollView>
<!-- Everything else! -->
</ScrollView>
<ImageView
android:id="#+id/full_screen_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</RelativeLayout>
Inside your Activity's onCreate() method:
#Override
public void onCreate(Bundle mySavedInstances) {
ImageView fullScreenContainer = (ImageView) findViewById(R.id.full_screen_container);
image1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//However it is you load your images
fullScreenContainer.setImageDrawawble(R.drawable.example);
fullScreenContainer.setVisibility(View.VISIBLE);
}
});
}
#Override
public void onBackPressed() {
if (fullScreenContainer.getVisibility() == View.VISIBLE) {
fullScreenContainer.setImageDrawable(null);
fullScreenContainer.setVisibility(View.GONE);
} else {
super.onBackPressed();
}
}
Welcome to stack overflow Dusan,
I've something very similar, but all I do is just put the full screen image in a new activity & pass the image as bytes & display it in a full screened imageview. As soon as they press back, they're returned to where they were before. I think trying to change the layout parameters is a bit overkill here.
Create new Activity or Fragment and set image to ImageView in new Activity or Fragment. Using Fragment is better approach here as user can click on multiple images one after another. It is less expensive to create or destory Fragment.
Image can be passed to another activity by converting into byte array. It is better approach to save image on server or database such as firebase etc and use generated URL in app. Which make it easy to pass Url between Activities or Fragments than passing byte array
Please excuse my English, I'm French !
I've got a listview, and I want to display an other activity on click on an item.
But the onItemClickListener seems to doesn't work...
I searched on Google, but but I found nothing.
Here my code:
The XML listView (custom) :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/activity_advert_list_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background" >
<RelativeLayout
android:id="#+id/advertBackground"
android:layout_width="339dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="7.5dp"
android:layout_marginTop="7.5dp"
android:background="#drawable/background_advert_list" >
<RelativeLayout
android:id="#+id/advertImageLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="8dp" >
<RelativeLayout
android:id="#+id/advertBackgroundLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grey" >
<ImageView
android:id="#+id/advertImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/advertPriceLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/advertImage"
android:layout_marginTop="-30.5dp"
android:background="#color/white_50" >
<TextView
android:id="#+id/advertPriceText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:hint="#string/Price"
android:paddingBottom="5dp"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:paddingTop="3dp"
android:textSize="14dp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/advertInfosLayout"
android:layout_width="305dp"
android:layout_height="47dp"
android:layout_below="#+id/advertImageLayout"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<RelativeLayout
android:id="#+id/advertInfosLayoutLayout"
android:layout_width="225dp"
android:layout_height="wrap_content"
android:layout_below="#+id/advertImageLayout" >
<TextView
android:id="#+id/advertTitleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Product_name"
android:textColor="#color/grey_blue"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/advertSizeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/advertTitleText"
android:hint="#string/Product_infos"
android:textColor="#color/b4b5b6"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/advertBookmarkLayout"
android:layout_width="74dp"
android:layout_height="45dp"
android:layout_toRightOf="#+id/advertInfosLayoutLayout" >
<Button
android:id="#+id/advertBookmarkIcon"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_centerVertical="true"
android:background="#drawable/bookmark" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/advertDistanceLayout"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<Button
android:id="#+id/advertDistanceIcon"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_centerHorizontal="true"
android:background="#drawable/distance" />
<TextView
android:id="#+id/advertDistanceText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/advertDistanceIcon"
android:layout_centerHorizontal="true"
android:text="13 km"
android:textColor="#color/grey_midark"
android:textSize="11sp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
The Java code :
list.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Start new detail activity
Intent intent = new Intent(activity, AdvertDetailActivity.class);
startActivity(intent);
Log.w("AdvertList", "Item clicked");
}
});
Have you got an idea ?
Thanks a lot !
If you're adding buttons/checkboxes to a ListView row, you should add this to them in the xml:
android:focusable="false"
Why? Because you have 2 click zones, the button and the row itself, so you have to put your row as the principal touch zone.
Try that to see if it works.
On the other hand, you have too many ViewGroups (RelativeLayouts) in your xml, which will make the draw process slower. Having only one (and maybe some LinearLayouts if you really need them) should be enough.
I have a RelativeLayout, we'll call this the 'slider', that I want to overlay on another RelativeLayout (by switching visibility="gone" and "visible") when "Add People" is clicked, but the overlay should only take up as much width of the screen as needed. This layout will then be removed when "Cancel" is clicked. Everything is working fine so far.
RelativeLayout slider;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_people);
RelativeLayout add = (RelativeLayout) findViewById(R.id.add_wrapper);
RelativeLayout cancel = (RelativeLayout) findViewById(R.id.cancel_wrapper);
slider = (RelativeLayout) findViewById(R.id.add_people_slider);
add.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
slider.setVisibility(View.VISIBLE);
}
});
cancel.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
slider.setVisibility(View.GONE);
}
});
}
The issue arises when I try to add another image to the slider. I am adding this just above the #id/cancel_wrapper RelativeLayout in the XML (full XML at bottom).
<ImageView
android:id="#+id/transparent_add"
android:src="#drawable/ic_add_active_256"
android:layout_height="30dp"
android:layout_width="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true" />
For some reason, this is making the width of the slider the full width of the screen.
What's even more bizarre is if I add android:layout_marginRight="50dp" to this ImageView to move it left a little it starts making the slider smaller from the left. I would like this "transparent_add" image to be lined up with the old "add" image.
My 2 issues, then, are that when I add the "transparent_add" image it changes the width of the slider for an unknown reason, and also when I add marginRight on the image it makes the width of the slider smaller from the left.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white" >
<TextView
android:id="#+id/btn_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingLeft="10dp"
android:text="#string/label_people"
android:textColor="#color/blue"
android:textSize="16dp" />
<TextView
android:id="#+id/people_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/btn_people"
android:paddingLeft="10dp"
android:text="#string/label_people_info"
android:textSize="11dp" />
<RelativeLayout
android:id="#+id/add_wrapper"
android:layout_width="65dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#color/blue" >
<ImageView
android:id="#+id/plus_sign"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="19dp"
android:layout_marginTop="6dp"
android:src="#drawable/ic_add_256" />
<TextView
android:id="#+id/add_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="2dp"
android:text="#string/label_add_people"
android:textColor="#color/white"
android:textSize="11dp" />
</RelativeLayout>
<ListView
android:id="#+id/contacts_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="#id/people_info" />
<!-- switch between visible/gone -->
<RelativeLayout
android:id="#+id/add_people_slider"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:background="#color/blue"
android:visibility="gone" >
<TextView
android:id="#+id/label_add_new_contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="65dp"
android:layout_alignParentTop="true"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:text="#string/label_add_new_contact"
android:textColor="#color/white"
android:textSize="16dp" />
<TextView
android:id="#+id/label_add_from_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/label_add_new_contact"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:paddingTop="15dp"
android:text="#string/label_add_from_phone"
android:textColor="#color/white"
android:textSize="16dp" />
<TextView
android:id="#+id/label_add_from_facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/label_add_from_phone"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:paddingTop="15dp"
android:text="#string/label_add_from_facebook"
android:textColor="#color/white"
android:textSize="16dp" />
<TextView
android:id="#+id/label_add_from_linkedin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/label_add_from_facebook"
android:paddingLeft="10dp"
android:paddingRight="15dp"
android:paddingTop="15dp"
android:text="#string/label_add_from_linkedin"
android:textColor="#color/white"
android:textSize="16dp" />
<!-- insert image here -->
<RelativeLayout
android:id="#+id/cancel_wrapper"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="10dp" >
<ImageView
android:id="#+id/image_cancel"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:src="#drawable/ic_close_256"/>
<TextView
android:id="#+id/label_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/label_cancel"
android:textColor="#color/white"
android:textSize="8dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
EDIT: This is happening both in Eclipse and on my Android device.
EDIT: I have tried placing the image above the "Add a new contact" text and then placing the text below that, but the same thing happens