How to make activity start at the bottom of the ScrollView? - android-activity

I want to make a quiz application with levels. It has a long background image and as you scroll down, at the bottom I have the levels 1, 2, 3,...going up. How can I make the activity scroll at the bottom automatically when I enter the app?!

ScrollView scrollview = findViewById(R.id.scrollView);
scrollview.post(new Runnable() {
#Override
public void run() {
scrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
});

Related

Flutter TabBar how to detect or listen for the being of drag or swipe?

I have a tab bar with a controller that has a Listener to handle the on tab and user drag/swipe the issue is that I need to know right at the being of the drag so I can start to make the active icon changes with the current version the active icon only changes at the end of the swipe so there is a delay.
Here is my code
In the init state
// For tab selection
tabController = TabController(vsync: this, length: 4);
tabController.addListener(_handleTabSelection);
// Handles the tab section with on tab and drag
void _handleTabSelection() {
setState(() {
_selectedIndex = tabController.index;
});
}

Flutter eye dropper

I am trying to find eye dropper for flutter or implement one. Can anybody help me with that?
I want to tap an image and get the colour of tapped area. Similar to an eyedropper for android.link
final View targetView = findViewById(R.id.targerView);
// Any view from which you want to pick the color
new EyeDropper(targetView, new ColorSelectionListener() {
#Override
public void onColorSelected(#ColorInt int color) {
// color is the color selected when you touch the targetView
(findViewById(R.id.colorSlot)).setBackgroundColor(color);
}
});
I just need something that allows me to pick a colour from an image just by tapping an area of an image and get the colour of that area.
I found a plugin for it. https://pub.dev/packages/cyclop it has the option you required.

Listview has Arrayadpater with edittext

I have single view layout with edit text and image. To display data in listview i am using arrayadapter . While entering value in Edit text in first row. The data gets repeated to another row in listview . How can i resolve this ?
View rowView = null;
try {
if (convertView == null) {
//inflating view.
rowView =
inflater.inflate(R.layout.list_single_view,null,false);
}
else
{
//Setting view if layout is already implemented.
rowView = convertView;
}
imageView = (ImageView)
rowView.findViewById(R.id.iv_activity_image_single);
//Facing issue here in editText . The entered text gets repeated
et_image_name = (EditText)
rowView.findViewById(R.id.txt_user_notes);
et_image_description = (EditText)
rowView.findViewById(R.id.txt_user_description);
//Loading image using universal image loader to imageView
if (equipmentPicturesList.get(position) != null) {
Constant.imageLoader.displayImage("file:///" +
equipmentPicturesList.get(position).toString(), imageView, Constant.options,
new SimpleImageLoadingListener());
}
else {
imageView.setBackgroundResource(R.drawable.ic_launcher);
}
}
catch (Exception e) {
Logger.loadStackTrace(e);
}
return rowView;
The EditText messes with the focus of whatever layout it is in. That can be a little tricky by itself, but in a ListView it causes all sorts of problems. But there is a way around that, it will work if you put the EditText inside the footer or header of the ListView with addHeaderView or addFooterView. The reason that it works in the header or footer is that the header and footer views are not recycled by the ListView. Alternatively you can call setHasTransientState() on the EditText to prevent it from being recycled even as a normal view inside the ListView.
But beware that turning off the view recycling - especially if you do it for multiple views - can impact performance and scrolling speed of the ListView.

How to have an Activity that uses a ScrollView AND keep onTouch method working properly?

I have an Activity that populates two views on a ViewFlipper. I added an onTouch(View v, MotionEvent event) public boolean method to the Activity. The method is implemented so that when the person taps on the screen the ViewFlipper goes to the next view. It works great but some of the text is too long so I went into my XML file and surrounded the textfield in one of my ViewFlipper views with a linearlayout and then a ScrollView. But now when I'm viewing the fields that are too long and show a scroll bar, I can't display the previous view. The onTouch method in my main activity isn't being executed. I have not been able to figure this out. I've read some posts about implementing or overriding the methods in ScrollView but I don't know where to do this in my activity. Does anyone know how I can program ScrollView to not intercept but keep its ability to scroll the view?
ScrollView myScroll;
myScroll.setOnTouchListener(new OnTouchListener){
#Override
public boolean onTouch(View v, MotionEvent touchevent) {
switch (touchevent.getAction()) {
case MotionEvent.ACTION_DOWN: {
oldTouchValue = touchevent.getX();
break;
}
case MotionEvent.ACTION_UP: {
float currentX = touchevent.getX();
if (oldTouchValue < currentX) {
//left swipe
return true;
}
if (oldTouchValue > currentX) {
//right swipe
return true;
}
return false;
}
}

Inconsistent text field.TouchDown firing when using a ScrollView

I'm using a UIScrollView for the first time, and I'm going crazy. I have several text boxes and labels on the scrollview. My text box event handled for TouchedDown, HandleTbLocationTouchDown (tb = Textbox), isn't firing half the time. My guess would be that the scrollview is swallowing the event because I have the exact same functionality on another View and it works perfectly fine.
Also, I set the size of the ScrollView in IB but that doesn't let it be scrollable. Setting it programmatically in my ViewDidLoad works though.
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Set the scrollableview
scrollView.Frame = new RectangleF(0,20, 320, 460);
// Set the initial scrollable view area size
scrollView.ContentSize = new SizeF(320, 550);
// For some reason this isn't always firing to do the offset,
// but the keyboard ALWAYS comes up.
tbLocation.TouchDown += HandleTbLocationTouchDown;
}
void HandleTbLocationTouchDown (object sender, EventArgs e)
{
scrollView.SetContentOffset(new PointF(0, 130), true);
}
Help?