ListView and SearchView bug [closed] - java

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
So I have a ListView in which I have filled random values. I also have a SearchView above the ListView. Whenever I click the SearchView, the Listview goes up. I do not want the Listview to be moved from its place. I am attaching two images for reference.
This is when the searchview is not active
This is when the searchview is active
Edit:: On emulator it works fine
CODE::`
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/NavigationBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="17dp"
android:adjustViewBounds="true"
android:padding="7dp"
android:src="#drawable/navigation_bar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="65dp"
android:layout_marginLeft="65dp"
android:layout_marginTop="17dp"
android:fontFamily="#font/product_sans_bold"
android:text="Library"
android:textColor="#color/green"
android:textSize="39sp" />
<ListView
android:id="#+id/ListView"
android:layout_width="match_parent"
android:layout_height="649dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginStart="0dp"
android:layout_marginBottom="0dp"
android:divider="#null" />
<androidx.appcompat.widget.SearchView
android:layout_width="362dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="76dp"
android:background="#drawable/search_background"
app:iconifiedByDefault="false"
app:queryBackground="#android:color/transparent"
app:queryHint="Search music"
app:searchHintIcon="#null"
app:searchIcon="#drawable/search" />
</RelativeLayout>
`
NOTE: I HAVE A CUSTOM LISTVIEW IN WHICH I AM FILLING VALUES. I HAVE NOT IMPLEMENTED SEARCHVIEW CODE TILL NOW.

Adding these lines of code solved the problem.
Hope this may help some coder.
android:focusableInTouchMode="false" android:isScrollContainer="false"

Related

Soft keyboard hides edit text

I'm create a login page and I have two normal credential edit text field,
the first one is for phone number and input type is number and it's ok,
here the problem with second edit text for password, I set input type to textPassword and I'm need to set text direction for both edit texts to RTL so I set gravity to right and when I set gravity to right just in Android 6.0.1 keyboard fill edit text (hide edit text field) and I can't see what I'm typing.
This 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"
tools:context="ir.samanjafari.recycelerviewitemanimation.LoginActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="forgot password"/>
<ImageView
android:id="#+id/logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#mipmap/ic_launcher_round"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="How are you guys?"
android:textSize="15sp"
android:textColor="#000"
android:layout_centerHorizontal="true"
android:layout_below="#id/logo"
android:layout_marginTop="15dp"/>
<LinearLayout
android:id="#+id/fields_lyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<EditText
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Phone"
android:gravity="right"
android:inputType="phone"/>
<EditText
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Password"
android:inputType="textPassword"
android:gravity="right"
android:layout_marginTop="15dp"/>
</LinearLayout>
<Button
android:layout_width="280dp"
android:layout_height="wrap_content"
android:layout_below="#id/fields_lyt"
android:layout_centerHorizontal="true"
android:text="Login"
android:layout_marginTop="40dp"/>
Inside the Android Manifest file, try adding the following attribute for your LoginActivity :
android:windowSoftInputMode="adjustPan"
or
android:windowSoftInputMode="adjustResize"
That will adjust the views so the keyboard doesn't hide them. There are different options for the mode. Have a look in the official documentation and see which one suits your needs teh best.
Use Scrollview and set android:fitsSystemWindows="true" in child layout and other way is use android:windowSoftInputMode="adjustPan" in specific activity tag in manifest

How to make a Login layout similar to this reference? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am creating an application in which I want to make a login screen similar to this. Kindly suggest the design of the last part of social media login.
Create a xml file like this for social media login part
=======
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue"
android:gravity="center"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="18dp">
<LinearLayout
android:id="#+id/social_icons"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="18dp"
android:layout_marginStart="18dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#drawable/rounded_corners"
android:gravity="center"
android:padding="15dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="#null"
android:src="#drawable/google_plus" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="24dp"
android:contentDescription="#null"
android:src="#drawable/google_plus" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="#null"
android:layout_marginStart="24dp"
android:src="#drawable/google_plus" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/blue"
android:textColor="#color/white"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:layout_centerHorizontal="true"
android:text="Login With"/>
</RelativeLayout>
</LinearLayout>

Android adding containers to a horizonalscollview [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have to admit my java is rusty and this is my first native Android app. I used Titanium studio a few years ago to build the same app.
I have a HorizontalScroll view outlined in my main_activity.xml and I want to add LinearLayout containers to it with data, each time a user presses a button. So my scroll view will start with nothing, and each button push will add another entry to it.
I tried something with a separate layout for the containers to be added, that use inflator, but then saw indications that I just define it all in the main activity layout. Maybe that was the correct route Here is the pertinent part of my layout
<HorfizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/ResultView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center"
android:onClick="onShowResult"
android:clickable="true"
android:visibility="gone"
android:id="#+id/ResultContainer">
<!--successes-->
<LinearLayout
android:orientation="horizontal"
android:weightSum="2"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="#string/success_label"
android:gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/Success_Label"
android:layout_weight="1"
android:clickable="false" />
<TextView
android:text=""
android:gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/Successes"
android:layout_weight="1"
android:clickable="false" />
</LinearLayout>
<!--tenss-->
<LinearLayout
android:orientation="horizontal"
android:weightSum="2"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="#string/tens_result_label"
android:gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/Tens_Result_Label"
android:layout_weight="1"
android:clickable="false" />
<TextView
android:text=""
android:gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/Tens_Result"
android:layout_weight="1"
android:clickable="false" />
</LinearLayout>
<!--ones-->
<LinearLayout
android:orientation="horizontal"
android:weightSum="2"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="#string/ones_result_label"
android:gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/Ones_Result_Label"
android:layout_weight="1"
android:clickable="false" />
<TextView
android:text=""
android:gravity="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/Ones_Result"
android:layout_weight="1"
android:clickable="false" />
</LinearLayout>
</LinearLayout>
And here is the code that I started playing with to implement it in my OnClick for the button. (the entries themselves will eventually be clickable) This is the only part of the onClick pertinent as the rest is just doing calculations, not creating the view being added.
//create and insert results
//start by getting the result view we plan to insert to
HorizontalScrollView resultview = (HorizontalScrollView)findViewById(R.id.ResultView);
//pull up the container to insert
LinearLayout resultcontainer = (LinearLayout)findViewById(R.id.ResultContainer);
//get and set the results
//add the container to the resultsview
resultview.addView(resultcontainer);
resultcontainer.setVisibility(View.VISIBLE);
This causes my app to crash and the debug seems to indicate it's something with an OnClick, but I wasn't clear. Specifically it looks like the addview in the second to last line causes the crash.
I'm fairly certain I'm not understanding something very fundamental and basic about how to do this, but like I said, kinda just diving in and learning as I go.
I also need to edit the text of the TextViews in the containers I'm adding, but one thing at a time.
Any help or pointers in the right direction would be appreciated.
So, my question, since apparently there was some confusion. What is the best way to add LinearLayouts to a HorrizontalScrollView, such that I can access and modify TextViews within those LinearLayouts?
Ideally, I'd like to create the objects being added initially via an XML layout, and not built them entirely programatically. Once created and modified, I'll add them to my HorrizontalScroll View.

Rendering xml file in Android Studio [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
This is my xml code in Android Studio. I am facing Rendering Problem in my Xml File.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.example.admin.myapp1.MainActivity1"
tools:showIn="#layout/activity_main1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="#+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Manab"
android:id="#+id/M_shaw"
android:layout_alignParentBottom="true"
android:layout_below="#+id/textView"
android:layout_alignStart="#+id/editText" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_below="#+id/textView"
android:layout_marginTop="62dp"
android:layout_alignEnd="#+id/editText2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/editText2"
android:layout_alignBottom="#+id/editText"
android:layout_toEndOf="#+id/textView"
android:text="45645" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Person1"
android:id="#+id/radioButton"
android:layout_below="#+id/editText"
android:layout_toEndOf="#+id/textView"
android:checked="true" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Person2"
android:id="#+id/radioButton2"
android:layout_below="#+id/radioButton"
android:layout_toEndOf="#+id/textView"
android:checked="false" />
</RelativeLayout>
error shown is-:
Exception raised during rendering: Binary XML file line #-1: Error inflating class
and also the error java.lang.NoSuchMethodError:
Help resolve this problem.
Seems that you have problem related to the Gradle cache.
Try the next step to "Refresh" your IDE (android studio)
1. Try Choose File | Invalidate Caches/Restart.

TextView not being displayed / Relative Layout

This might seem like a very easy question for some of you folks, but I can't find a way to display my TextView even after trying numerous solutions proposed on this site. Not that I am using the built-in Eclipse XML tool for Android and that the TextView is visible on this graphical layout. Here's what I've got so far :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:contentDescription="#string/no_of_screens"
android:id="#+id/imageViewHome"
android:layout_width="290dp"
android:layout_height="212dp"
android:layout_gravity="center_horizontal"
android:paddingTop="40dp"
android:src="#drawable/logo" />
<RelativeLayout
android:id="#+id/relativeid"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<Button
android:id="#+id/launch_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="80dp"
android:text="#string/launch" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/launch_button"
android:layout_marginRight="20dp"
android:layout_toLeftOf="#+id/launch_button"
android:entries="#array/num_array"
android:prompt="#string/screen_prompt"
android:textSize="8pt" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/launch_button"
android:layout_alignBottom="#+id/launch_button"
android:layout_marginRight="16dp"
android:layout_toLeftOf="#+id/spinner1"
android:text="#string/no_of_screens"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</LinearLayout>
As for now, all of the other elements are being displayed correctly. Any help would be greatly appreciated!
Thanks
Where do you want your textView?
I would loose these two:
layout_alignBaseline="#+id/launch_button
layout_alignBottom="#+id/launch_button
and use one of these:
layout_below="#+id/launch_button
layout_above="#+id/launch_button
That will put it either above or below the button.

Categories

Resources