I have following layout includes a NestedScrollView(it has a RecyclerView inside) :
<android.support.constraint.motion.MotionLayout
android:id="#+id/details_motion"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="#xml/scene_show_details">
<ImageView
android:id="#+id/details_backdrop"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:imageUrl="#{movie.backdropPath}"
tools:ignore="ContentDescription" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/details_poster"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#drawable/placeholder"
android:scaleType="centerCrop"
android:transformPivotX="0px"
android:transformPivotY="0px"
android:transitionName="#string/view_name_header_image"
app:imageUrl="#{movie.posterPath}" />
<android.support.v7.widget.Toolbar
android:id="#+id/details_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="#style/Toolbar" />
<android.support.v4.widget.NestedScrollView
android:id="#+id/details_rv"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#color/window_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/details_appbar_background">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="#style/TmdbMargin.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/padding_normal"
android:text="#{#string/release_date(movie.releaseDate)}" />
<TextView
style="#style/TmdbMargin.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{#string/rating(movie.voteAverage)}" />
<TextView
style="#style/TmdbMargin.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/summary" />
<TextView
android:id="#+id/summary"
style="#style/TmdbMargin.Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{movie.overview}" />
<include
layout="#layout/trailers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/padding_normal"
android:layout_marginTop="#dimen/padding_large"
app:vm="#{vm}"
tools:ignore="RtlHardcoded" />
<TextView
style="#style/TmdbMargin.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/padding_normal"
android:text="#string/cast"
app:visibleGone="#{vm.isCastVisible}" />
<android.support.v7.widget.RecyclerView
android:id="#+id/cast_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.constraint.motion.MotionLayout>
When I rotate the device (for instance when I am in the middle of RecyclerView list), I want to scroll to top of NestedScrollView. I tried :
nestedScrollView.fullScroll(View.FOCUS_UP);
nestedScrollView.scrollTo(0,0);
But none of them worked in my case. Could be any solution for me?
Source code can be found at : https://github.com/Ali-Rezaei/TMDb-Paging
I downloaded your app, problem is a while you trying to set scrollTo(0,0) or through fullScroll(View.FOCUS_UP), your list has not been initialized / rendered, list is empty when you calling operation scroll to top. Easy workaround is delayed your scroll operation (not so perfect way):
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Your code ....
// ....
nestedScrollView = view.findViewById<NestedScrollView>(R.id.details_rv)
nestedScrollView.postDelayed({
nestedScrollView.scrollTo(0, 0)
}, 100)
}
While searched solution found a lot of great animations. You are MotionLayout monster :)
Related
here is my XML code which I am trying. I wrote the code in the right way but I can't get the results I want so please tell me where I am mistaken in coding thanks in advance for the help.
<ScrollView
android:id="#+id/tabLOScroll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#color/toolBarClr"
android:fillViewport="true"
android:scrollbars="horizontal"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/appBar">
<LinearLayout
android:id="#+id/tabLO"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal">
<include
layout="#layout/custome_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp" />
<include
layout="#layout/custome_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp" />
<include
layout="#layout/custome_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp" />
<include
layout="#layout/custome_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp" />
<include
layout="#layout/custome_tab_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp" />
</LinearLayout>
</ScrollView>
this just shows 4 tabs but I add 5 I want to scroll to see the 5th but the horizontal scroll not working
ScrollView supports vertical scrolling only. If you want horizontal scrolling, you need to use HorizontalScrollView. The documentation for ScrollView actually says exactly this.
I am trying to build SIP call application using Pjsip and so far it is working good.
I am facing one issue in displaying video window.
I am using surface view to display streaming frames.
Please see the attached image below:
I want to remove Black space on both side of my preview.
UI Part:
<?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"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent">
<SurfaceView
android:id="#+id/surfaceIncomingVideo"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<SurfaceView
android:id="#+id/surfacePreviewCapture"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_width="#dimen/_100sdp"
android:layout_marginBottom="#dimen/_70sdp"
android:layout_height="#dimen/_130sdp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
app:elevation="0dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:id="#+id/layoutCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="#id/ivBack"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#id/ivBack">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivHabariLogo"
android:layout_width="27dp"
android:layout_height="37dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/call_ic_habari_logo" />
<android.support.v7.widget.AppCompatTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_8sdp"
android:fontFamily="#font/helvetica_neue_regular"
android:text="#string/toolbar_title_video"
android:textSize="#dimen/_14ssp"
android:textColor="#color/grey"
app:layout_constraintBottom_toBottomOf="#+id/ivHabariLogo"
app:layout_constraintStart_toEndOf="#+id/ivHabariLogo"
app:layout_constraintTop_toTopOf="#+id/ivHabariLogo" />
</android.support.constraint.ConstraintLayout>
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivBack"
android:layout_width="wrap_content"
android:layout_height="?android:attr/actionBarSize"
android:paddingStart="21dp"
android:paddingEnd="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/back_arrow_white" />
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/layoutUser"
android:layout_marginTop="#dimen/_24sdp"
android:layout_width="match_parent"
android:layout_height="#dimen/_100sdp" >
<RippleBackground
android:id="#+id/callRinging"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rb_color="#color/ringing_1"
android:layout_gravity="center"
app:rb_duration="2500"
app:rb_radius="#dimen/_40sdp"
app:rb_rippleAmount="3"
app:rb_scale="2">
</RippleBackground>
<RadarViewUsersView
android:id="#+id/radarViewUser"
android:layout_width="#dimen/_100sdp"
android:layout_height="#dimen/_100sdp"
android:layout_gravity="center">
</RadarViewUsersView>
</FrameLayout>
<android.support.v7.widget.AppCompatTextView
android:id="#+id/tvCalleeName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="#dimen/_8sdp"
android:textColor="#color/white"
android:textSize="#dimen/_16ssp"
android:fontFamily="#font/helvetica_neue_regular" />
<android.support.v7.widget.AppCompatTextView
android:id="#+id/tvCallState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#color/white"
android:text="#string/sip_call_state_calling"
android:fontFamily="#font/helvetica_neue_regular"
android:layout_marginTop="#dimen/_2sdp"
android:textSize="#dimen/_12ssp" />
</LinearLayout>
</FrameLayout>
<LinearLayout
android:id="#+id/layoutOutgoingCall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/_24sdp"
android:visibility="visible"
android:orientation="vertical">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivEndCall"
android:layout_width="wrap_content"
android:layout_weight="0.25"
android:layout_gravity="center"
android:layout_marginStart="#dimen/_8sdp"
android:layout_marginEnd="#dimen/_8sdp"
android:layout_height="0dp"
android:padding="#dimen/_16sdp"
app:srcCompat="#drawable/ic_call_reject" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivSwitchCamera"
android:layout_width="0dp"
android:layout_weight="0.33"
android:layout_gravity="center"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_switch_camera" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivDisableVideoCall"
android:layout_width="0dp"
android:layout_weight="0.33"
android:layout_marginStart="#dimen/_8sdp"
android:layout_marginEnd="#dimen/_8sdp"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_video_cam_off" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivMuteVoiceCall"
android:layout_width="0dp"
android:layout_weight="0.33"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_video_mic_on" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/layoutIncomingCall"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginBottom="#dimen/_16sdp"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivRejectCall"
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_call_reject" />
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ivAcceptCall"
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_call_accept" />
</LinearLayout>
</RelativeLayout>
Code Part:
In onCreate():
surfaceIncomingVideo.holder.addCallback(this)
surfacePreviewCapture.holder.addCallback(previewHandler)
When preview received:
fun updateVideoPreview(holder: SurfaceHolder) {
if (SipManager.currentCall != null &&
SipManager.currentCall?.mVideoWindow != null &&
SipManager.currentCall?.mVideoPreview != null) {
if (videoPreviewActive) {
val vidWH = VideoWindowHandle()
vidWH.handle?.setWindow(holder.surface)
val vidPrevParam = VideoPreviewOpParam()
vidPrevParam.window = vidWH
try {
SipManager.currentCall?.mVideoPreview?.start(vidPrevParam)
} catch (e: Exception) {
println(e)
}
} else {
try {
SipManager.currentCall?.mVideoPreview?.stop()
} catch (e: Exception) {
println(e)
}
}
}
}
Can anyone help me with that?
Thank you in advance!
Okay so finally I got an answer. It was because of orient I ahve set to rotate my camera view. I think it's internal pjsip issue.
I won't go into ultra details on how to do this but the general idea is this:
A) This is a known / accepted issue with PJSIP. The developer(s) have stated that its "to be expected".
B) The way around this takes a few hoops to jump through:
Add a header to outgoing calls stating your current orientation. DO NOT, change it using PJSIP.
Have your SIP server forward this header to the target client.
Have the target client read this header and rotate the video on the android end.
I am dealing with this as we speak and have the orientation arriving at my view. I'm fairly new to android development so I now need to figure out how to rotate a surfaceview (setRotation not working...) and after how to send an additional request to the client when the orientation changes.
But thats the basic idea... If you want to get rid of the bars and deal with the black bars, thats the route to go.
I have 3 HorizontalScrollview, for each of them i have customView contain editText that i add dynamically depend from web service response. The problem is, when i want to change value in editText and keyboard appear, the HorizontalScrollView scroll automatically to the end, so i can't properly input value to my edit text. My Question is how to prevent autoscroll in my HorizontalScrollView so i can input value on my editText? and the HorizontalScrollView only scroll when user scroll it.
I've search and my problem similar with this thread but the sugestion didn't work. here is workaround that i already try :
Add android:windowSoftInputMode="stateHidden|adjustNothing" or
android:windowSoftInputMode="stateHidden|adjustResize" already try
adjustPan and other combination but it's impact nothing.
Add android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true" in LinearLayout inside my HorizontalScrollView and it's also impact Nothing.
Add android:descendantFocusability="blocksDescendants the
HorizontalScrollView didn't scroll automatically but i can't change value on my edit text, it similar when i add android:focusable = "false" in my editText
Add code bellow but impact nothing.
scrollLayout.descendantFocusability = ViewGroup.FOCUS_BEFORE_DESCENDANTS
scrollLayout.isFocusable = true
scrollLayout.isFocusableInTouchMode = true
scrollLayout.setOnTouchListener { v, event ->
v.requestFocusFromTouch()
false}
Here is My Code
private fun setUpList(rootLayout: LinearLayout, scrollLayout: HorizontalScrollView, items: List<ProductItem>) {
//config horizontal scroll view
scrollLayout.descendantFocusability = ViewGroup.FOCUS_BEFORE_DESCENDANTS
scrollLayout.isFocusable = true
scrollLayout.isFocusableInTouchMode = true
scrollLayout.setOnTouchListener { v, event ->
v.requestFocusFromTouch()
false
}
// add customView to linear layout
rootLayout.removeAllViews()
for (item in items) {
val view = EditableThumbnailProduct(context)
view.setProductInfo(item)
view.setOnProductChangeListener(onChangeListener())
rootLayout.setBackgroundColor(Color.TRANSPARENT)
rootLayout.addView(view)
}
}
Here is my XML
<HorizontalScrollView
android:id="#+id/scrollMed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:id="#+id/contentMed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#android:color/transparent"
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal" />
</HorizontalScrollView>
Here is my custom view
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#android:color/transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<ImageView
android:id="#+id/img_thumbnail"
android:layout_width="150dp"
android:layout_height="120dp"
android:background="#color/gray_border"
android:scaleType="fitXY" />
<TextView
android:id="#+id/txt_product_name"
style="#style/DefaultTextTitle"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_margin="5dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="2"
android:text="#string/product_name_label" />
<TextView
android:id="#+id/txt_product_stock"
style="#style/DefaultTextSubTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center"
android:text="#string/available_stock_label" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray_border" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<Button
android:id="#+id/btn_add_to_cart"
style="#style/WhiteTitle"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:background="#drawable/round_button_orange"
android:gravity="center"
android:text="#string/buy_button_label"
android:visibility="invisible" />
<RelativeLayout
android:id="#+id/layout_plus_minus"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/btn_minus"
style="#style/WhiteTitle"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:background="#drawable/round_button_blue"
android:paddingLeft="5dp"
android:paddingTop="11dp"
android:paddingRight="5dp"
android:paddingBottom="11dp"
android:scaleType="fitXY"
app:srcCompat="#drawable/ic_minus" />
<ImageView
android:id="#+id/btn_delete"
style="#style/WhiteTitle"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:background="#drawable/round_button_blue"
android:padding="3dp"
android:scaleType="fitXY"
android:visibility="invisible"
app:srcCompat="#drawable/ic_delete" />
<EditText
android:id="#+id/txt_cart_amount"
style="#style/LightTextTitle"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_marginLeft="40dp"
android:layout_marginRight="10dp"
android:backgroundTint="#color/blue_text_color"
android:inputType="number"
android:maxLength="3"
android:paddingBottom="5dp" />
<ImageView
android:id="#+id/btn_plus"
style="#style/WhiteTitle"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:background="#drawable/round_button_blue"
android:gravity="center"
android:padding="5dp"
android:scaleType="fitXY"
android:textSize="16sp"
app:srcCompat="#drawable/ic_plus" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
All sugestion will be appreciate. Thanks in advance.
I want create a View the same Image.
Touch value on View:
I using the solution create TextView and touch on TextView:
This is layout xml: i create 6 TextViews to display value when Touch on Screen.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtPreSelect1"
android:layout_width="#dimen/d_60"
android:layout_height="match_parent"
android:gravity="center"
android:text="000"
/>
<TextView
android:id="#+id/txtPreSelect2"
android:layout_width="#dimen/d_60"
android:layout_height="match_parent"
android:gravity="center"
android:text="0"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="200dp"
android:layout_height="1dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtSelect1"
android:layout_width="#dimen/d_60"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/d_40"
android:gravity="center"
android:text="001"
/>
<TextView
android:id="#+id/txtSelect2"
android:layout_width="#dimen/d_60"
android:layout_height="match_parent"
android:gravity="center"
android:text="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="200dp"
android:layout_height="1dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/txtNextSelect1"
android:layout_width="#dimen/d_60"
android:layout_height="match_parent"
android:layout_marginRight="#dimen/d_40"
android:gravity="center"
android:text="002"
/>
<TextView
android:id="#+id/txtNextSelect2"
android:layout_width="#dimen/d_60"
android:layout_height="match_parent"
android:gravity="center"
android:text="2"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center|right"
android:orientation="horizontal">
<TextView
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:gravity="center"
android:text="#string/btnCancel"/>
<TextView
android:id="#+id/btnOK"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="#string/btnOK"
/>
</LinearLayout>
</LinearLayout>
and i create event Touch on TextViews, to change value of Textview:
dialog.txtPreSelect1.setOnTouchListener {v: View, event: MotionEvent ->
// Perform tasks here
when (event.action)
{
MotionEvent.ACTION_DOWN ->{
yValue=event.y
}
MotionEvent.ACTION_MOVE ->{
val curentY=event.y
if(curentY>yValue)
{
if(curentY>yValue) {
yValue=curentY
var iStartValue=dialog.txtPreSelect1.text.toString().toInt() - iStep1
dialog.txtPreSelect1.text = iStartValue.toString()
iStartValue=iStartValue +iStep1
dialog.txtSelect1.text = iStartValue.toString()
iStartValue=iStartValue +iStep1 dialog.txtNextSelect1.text = iStartValue.toString()
}
}
else if(curentY<yValue)
{
if(curentY<yValue) {
yValue=curentY
var iStartValue=dialog.txtPreSelect1.text.toString().toInt() + iStep1
dialog.txtPreSelect1.text = iStartValue.toString()
iStartValue += iStep1
dialog.txtSelect1.text = iStartValue.toString()
dialog.txtNextSelect1.text = iStartValue.toString()
}
}
}
}
true
}
How can create event move text the same image 2?
Or Exist other View can process my work?
Thank all.
If I understand correctly your problem is in creating two views with lists, so you can touch and scroll them separately.
You can try to dive into this library that is quite similar what you are trying to reach: SingleDateAndTimePicker
My best guess is you want to use native component. You can use ListView but that would require much code than Number Picker. Number Picker is specifically designed to handle such situations.
Here in SO a Nice example can show you how to use it in dialog. Basically you need a LinearLayout with Horizontal Orientation and place two Number Picker inside it.
You can set MinValue and MaxValue with the help of java/kotlin like this:
numberPicker.setMaxValue(50);
numberPicker.setMinValue(1);
let me know if you have any query.
I am using coardinate layout with recyclerview in viewpager and tablayout. I have a view for banner which i want to show over the recyclerview at the bottom. This bottom view is only visible if i scroll up the recyclerview list and hides when i scrollback down.I want this view to be visible all the time over recyclerview. Any help will be appreciated. Thanks in advance.r image description here]1]1
Here is my xml code
<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:background="#color/deal_display_bg"
tools:context="com.safar.spicedeals_activities.DealsActivity$PlaceholderFragment">
<View
android:id="#+id/topview_deal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_alignParentTop="true"
android:background="#color/spice_laddooblue"
android:visibility="gone" />
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<TextView
android:id="#+id/no_deals_available"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/no_deals_available"
android:textColor="#color/spice_laddooblue"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="gone" />
<FrameLayout
android:id="#+id/frameLayoutDeals"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bannerView"
android:layout_below="#+id/topview_deal"
android:padding="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ProgressBar
android:id="#+id/progressBarDeals"
style="?android:attr/android:progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- </android.support.v4.widget.SwipeRefreshLayout> -->
</FrameLayout>
<RelativeLayout
android:id="#+id/relativeLayout_PriceTotal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/background_with_border_square"
android:padding="10dp"
android:visibility="gone">
<TextView
android:id="#+id/textView_totalPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="#string/total_price"
android:textColor="#color/spice_laddooblue"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_totalPriceResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignTop="#+id/textView_totalPrice"
android:layout_marginLeft="3dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="#+id/textView_totalPrice"
android:textColor="#color/spice_laddooblue"
android:textSize="15sp"
android:textStyle="bold" />
<Button
android:id="#+id/button_processDeal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_totalPrice"
android:layout_marginTop="10dp"
android:background="#color/spice_laddooblue"
android:text="#string/proceed_tag"
android:textColor="#color/White"
android:textStyle="italic" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bannerView"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:background="#drawable/curved_white_with_blue_border"
android:visibility="gone">
<TextView
android:id="#+id/bannerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="3dp"
android:text="Banner"
android:visibility="gone" />
<ImageView
android:id="#+id/bannerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="3dp"
android:scaleType="fitXY"
android:visibility="gone" />
<ImageView
android:id="#+id/bannerClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:src="#drawable/cross_icon" />
</RelativeLayout>
</RelativeLayout>
This worked for me! add this attribute for your android.support.v7.widget.Toolbar
app:layout_scrollFlags="scroll"
The app:layout_scrollFlags attribute of the Toolbar indicates to the view how to respond. It has the following possible values.
scroll :
This flag is generally set for all views that need to
scroll off-screen. Views that don’t use this flag remain static
allowing the other scrollable views to slide behind it.
enterAlways :
This flag ensures that any downward scroll will cause the view to
become visible, enabling the quick return pattern.
enterAlwaysCollapsed :
An additional flag for ‘enterAlways’ which
modifies the returning view to only initially scroll back to it’s
collapsed height.
exitUntilCollapsed :
This flag causes the view to
be scrolled until it is collapsed (its minHeight is reached) before
exiting
snap : Upon a scroll ending, if the view is only partially
visible then it will be snapped and scrolled to it’s closest edge.
Hence this avoids mid-animation states of a view
More details can be found here.