Android scroll to top next replacing fragment in scrollview - java

this is my layout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="#+id/main_scrollview"
android:layout_width="match_parent"
android:scrollbars="vertical"
android:fillViewport="true"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/space.small"
android:orientation="vertical"
android:padding="#dimen/space.medium">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="#dimen/space.medium">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/bla_bla_bla"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/my_relative_layout">
</RelativeLayout>
</LinearLayout>
</ScrollView>
it is a fragment inside my tab menu, when this tab will be create the relative layout will be replaced by a variable number of elements:
android.support.v4.app.FragmentTransaction ft = getChildFragmentManager().beginTransaction();
ft.replace(R.id.my_relative_layout, myListFragment).commit();
mHolder.scrollView.scrollTo(0,0); //not work
But my fragment doesn't scroll to top, it works only with a delay like:
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
#Override
public void run() {
mHolder.scrollView.scrollTo(0,0);
}
}, 100);
How can I do that in a right way? I won't use a delay

Add
android:descendantFocusability="blocksDescendants"
to
"RelativeLayout"

Related

Nested Scroll View Not Scroll to Bottom of Activity

I am having an issue with nested scroll view when reach bottom.
Inside nestedScrollView I have a button, in bottom of page I have a input field to enter phone number. When press button, if phone number filed not filled, I want to scroll to Bottom of Activity to highlight input field.
But in my activity it scrolling only half, not scrolling till end.
I tried all beloved java codes to fix this issue, but all works same (Not reaching bottom, stops on middle).
Java Codes
CoordinatorLayout mainCoordinate = findViewById(R.id.mainCoordinate);
NestedScrollView nestedScrollView = findViewById(R.id.nestedScroll);
1.
//Scroll to bottom of view
nestedScrollView.post(new Runnable() {
#Override
public void run() {
nestedScrollView.smoothScrollTo(0, mainCoordinate.getBottom());
}
});
2.
//Scroll to bottom of view
nestedScrollView.post(new Runnable() {
#Override
public void run() {
nestedScrollView.fullScroll(View.FOCUS_DOWN);
}
});
3.
nestedScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
final int scrollViewHeight = nestedScrollView.getHeight();
if (scrollViewHeight > 0) {
nestedScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
final View lastView = nestedScrollView.getChildAt(nestedScrollView.getChildCount() - 1);
final int lastViewBottom = lastView.getBottom() + nestedScrollView.getPaddingBottom();
final int deltaScrollY = lastViewBottom - scrollViewHeight - nestedScrollView.getScrollY();
/* If you want to see the scroll animation, call this. */
nestedScrollView.smoothScrollBy(0, deltaScrollY);
/* If you don't want, call this. */
nestedScrollView.scrollBy(0, deltaScrollY);
}
}
});
XML Codes
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:id="#+id/mainCoordinate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
tools:ignore="RtlHardcoded">
<android.support.design.widget.AppBarLayout
android:id="#+id/flexibleAppbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:visibility="invisible">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/flexible.example.collapsing"
android:layout_width="match_parent"
android:layout_height="258dp"
app:contentScrim="?colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/imageMain"
android:layout_width="match_parent"
android:layout_height="258dp"
android:foreground="#drawable/ripple_effect_circle_card"
android:src="#drawable/back_button_white" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
app:behavior_overlapTop="48dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/price.card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchorGravity="bottom"
card_view:cardBackgroundColor="#color/card_back"
card_view:cardCornerRadius="4dp"
card_view:contentPadding="8dp">
.........................
.........................
.........................
//My Other All Views
.........................
.........................
.........................
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile.card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchorGravity="bottom"
card_view:cardBackgroundColor="#color/card_back"
card_view:cardCornerRadius="4dp"
card_view:contentPadding="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:padding="5dp"
android:text="Phone No." />
<EditText
android:id="#+id/etPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="end"
android:hint="Enter your phone"
android:inputType="phone"
android:text=""/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<Button
android:id="#+id/btnBookNow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"/>
</android.support.design.widget.CoordinatorLayout>
I attached a video that explains my exact problem link
Please, Does anyone having a better way or other suggestion to fix this issue?
Thanks in Advance
Pls try Android layout inspector to check height of your NestedScroll.
Try to add
android:layout_gravity="bottom|center" to Button.
In NestedScrollView set layout heigh to android:layout_height="wrap_content"

open fragment under parent activity

I want to open a fragment in activity but under objects of Activity.
in my code RelativeLayout is parent and LinearLayout is child
but when open fragment on relativelayout I lose linearlayout :(
this is my code:
Main Activity Java:
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private Context context;
private Button fragment1 , fragment2;
private RelativeLayout relativeLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context = getApplicationContext();
fragment1 = this.findViewById(R.id.fragment1);
fragment2 = this.findViewById(R.id.fragment2);
relativeLayout = this.findViewById(R.id.relativeLayout);
fragment1.setOnClickListener(this);
fragment2.setOnClickListener(this);
}
#Override
public void onClick(View view) {
switch (view.getId()){
case R.id.fragment1:
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.relativeLayout , new fragment1());
ft.commit();
break;
case R.id.fragment2:
FragmentManager fm2 = getSupportFragmentManager();
FragmentTransaction ft2 = fm2.beginTransaction();
ft2.replace(R.id.relativeLayout , new fragment2());
ft2.commit();
break;
}
}
}
Main Activity XML:
<?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"
android:id="#+id/relativeLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/layout"
android:background="#F00"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fragment 1"
android:id="#+id/fragment1"
android:gravity="center"
android:layout_gravity="center"/>
<Button
android:id="#+id/fragment2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="fragment 2" />
</LinearLayout>
</RelativeLayout>
fragment1 XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0F0">
</android.support.constraint.ConstraintLayout>
fragment2 XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00F">
</android.support.constraint.ConstraintLayout>
This is Main Activity: enter image description here
and when click on fragment1: enter image description here
Plz Help Me :)
TNX
Add a framelayout in relativelayout before the linearlayout and inflate the fragment in the framelayout.
<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"
android:id="#+id/relativeLayout">
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout"
android:background="#F00"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fragment 1"
android:id="#+id/fragment1"
android:gravity="center"
android:layout_gravity="center"/>
<Button
android:id="#+id/fragment2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="fragment 2" />
</LinearLayout>
</RelativeLayout>
I think you should change your Fragment1 XML and Fragment2 XML from Constraint Layout to LinearLayout. It should work else initiate your LineaLayout in your MainActivity.
You are inflating fragments on Parent Layout. Make two child of Relativelayout and inflate fragment one of them like this:
<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"
android:id="#+id/relativeLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout"
android:background="#F00"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fragment 1"
android:id="#+id/fragment1"
android:gravity="center"
android:layout_gravity="center"/>
<Button
android:id="#+id/fragment2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="fragment 2" />
</LinearLayout>
<!-- inflate fragments on FrameLayout -->
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/linearLayout">
</FrameLayout>
</RelativeLayout>
Inflate your fragments on this FrameLayout
....Hope this helps :)

Add fragment below another overlapping

I'm was trying to display fragment below another fragment, but i'm facing Issue with view, when i invoke the 2nd fragment that should come below first fragment it's overlap.
My First fragment container RelativeLayout with Id mainLayout and 2nd fragment with Id carLayout.
I assume the issue with XML code.
My XML
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/topLayout">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:layout_weight="1" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/mainLayout">
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/carLayout">
</RelativeLayout>
</LinearLayout>
i need to set fragment 2 below fragment 1
but it'as overlapping.
as I understand you need to set two fragment in same view
// add your first fragment
FragmentTransaction transaction = getFragmentManager().beginTransaction().add(frame_container1 , YOUR_FIRST_FRAGMENT).commit;
// add your second fragment
FragmentTransaction transaction = getFragmentManager().beginTransaction().add(frame_container2 , YOUR_SECOND_FRAGMENT).commit;
<linearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2">
<FrameLayout
android:id="#+id/frame_container1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="#+id/frame_container2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</linearLayout>
or simply
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="YOUR FRAGMENT CLASS"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</fragment>
carLayout is a RelativeLayout so new fragment will be over the last one, change it to a LinearLayout with orientation vertical.
You need another view below your carLayout.
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/anotherLayout"
android:layout_below="#id/carLayout">
</RelativeLayout>
The 'add' method adds a fragment to a view, so you can modify your method to use a different container every time:
public void replaceFragment(Fragment someFragment, int containerId) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.add(containerId , someFragment);
transaction.addToBackStack(null);
transaction.commit();
}
case R.id.home_menu:
fragment = new mainFrog();
replaceFragment(fragment,R.id.carLayout);
public void Haraj_cars(View view) {
fragment = new carFrog();
replaceFragment(fragment,R.id.anotherLayout);
}

Get only top part of camera

I am stuck at this Issue since couple of days. What I want is only part of the camera to be shown on screen. This is what I want:
This is what I have done:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="160dp"
android:scrollbars="none"
android:fillViewport="true"
>
<LinearLayout
android:id="#+id/linearLayoutBeautyContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/surfaceViewBeautyCamera"/>
</LinearLayout>
</ScrollView>
<TextView
android:id="#+id/scanText"
android:text="Scanning..."
android:layout_height="wrap_content"
android:layout_width="match_parent">
</TextView>
</LinearLayout>
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final LayoutInflater inflator = getLayoutInflater();
final LinearLayout inflate = (LinearLayout) inflator.inflate(R.layout.main, null);
final SurfaceView surfaceView = (SurfaceView) inflate.findViewById(R.id.surfaceViewBeautyCamera);
final SurfaceHolder holder = surfaceView.getHolder();
WindowManager mW = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
int screenWidth = mW.getDefaultDisplay().getWidth();
int screenHeight = mW.getDefaultDisplay().getHeight();
final ViewGroup.LayoutParams slayout = surfaceView.getLayoutParams();
slayout.width = screenWidth;
slayout.height = screenHeight;
surfaceView.requestLayout();
final ScrollView beautyContent = (ScrollView) inflate.findViewById(R.id.scrollView);
holder.addCallback(new SurfaceHolder.Callback() {
#Override
public void surfaceCreated(SurfaceHolder holder) {
try {
camera = getCamera();
camera.setPreviewDisplay(holder);
camera.setDisplayOrientation(90);
camera.startPreview();
} catch (IOException e) {
Log.i("Lucy", e.getMessage());
}
}
#Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
#Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
});
addContentView(inflate, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
}
public Camera getCamera() {
try {
final Camera open = Camera.open();
return open;
} catch (Exception ex) {
Log.i("Lucy", ex.getMessage());
return null;
}
}
When i do this I get:
The Idea is to set the size of SurfaceView as full screen but reduce the size of scroll view. But what I want is the first Image. What am I doing wrong?
Observations:
When I scroll the view up completely. Go back to Home Screen and open the app again. i get the first image. But if I scroll again and go back to main to come back, i get the second Image.
Any other strategy?
PS:
1. Having other view on top of camera is also option, but I cannot use it for lengthy reasons
The problem is the height settings for your elements:
Your root element should be a relative layout, you can then set the fixed height of the camera view and set the textview with the text to height match parent and layout_below the scroll view.
try this layout.But don't understand why use scrollView.
I post 2 layout
First one where surface mean camera face is 160dp
<?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:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayoutBeautyContent"
android:layout_width="fill_parent"
android:layout_height="160dp"
android:orientation="vertical" >
<SurfaceView
android:id="#+id/surfaceViewBeautyCamera"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<TextView
android:id="#+id/scanText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="#id/linearLayoutBeautyContent"
android:background="#000000"
android:text="Scanning..." >
</TextView>
</RelativeLayout>
2nd one is, camera will capture fullscreen size picture but u can see only 160 window at time of capture
<?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:orientation="vertical" >
<LinearLayout
android:id="#+id/linearLayoutBeautyContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<SurfaceView
android:id="#+id/surfaceViewBeautyCamera"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<TextView
android:id="#+id/scanText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_marginTop="160dp"
android:background="#000000"
android:text="Scanning..." >
</TextView>
</RelativeLayout>
I dont know why you put surfaceView in the scrollView But I put up with your layout file and its works for me as you show in expected snapshot result .
Edits:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fillViewport="true"
android:scrollbars="none" >
<LinearLayout
android:id="#+id/linearLayoutBeautyContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<SurfaceView
android:id="#+id/surfaceViewBeautyCamera"
android:layout_width="match_parent"
android:layout_height="160dp" />
<TextView
android:id="#+id/scanText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Scanning..." >
</TextView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</LinearLayout>

Scroll Bar in List View

Why is there a Scroll Bar in List View even when the data in displayed in it doesn't require scrolling?
here is my xml file
<LinearLayout 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="#drawable/background"
android:orientation="vertical" >
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null"
android:dividerHeight="0dip" />
<TextView
android:id="#+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/no_result_text"
android:visibility="gone" />
</LinearLayout>
Comparing getLastVisiblePosition() with getCount() in a Runnable, you will get to know whether your list view will fit into the screen or not. Also check if the last visible row fits entirely on the screen or not.
ListView listView;
Runnable fitsOnScreen = new Runnable() {
#Override
public void run() {
int last = listView.getLastVisiblePosition();
if(last == listView.getCount() - 1 && listView.getChildAt(last).getBottom() <= listView.getHeight()) {
listView.setScrollContainer(false);
}
else {
listView.setScrollContainer(true);
}
}
};
Finally in ListView's Handler: onCreate()
listView.post(fitsOnScreen);
You can do this by
listView.setScrollContainer(false);
for more please check
How to get a non scrollable ListView?
If you are not want to hide the scrollbar for ever. Then it will help you.
Due to android:layout_height="match_parent" on listView and TextView scrollbar appears.
<LinearLayout 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="#drawable/background"
android:orientation="vertical" >
<ListView
android:id="#+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content" // change 1
android:divider="#null"
android:dividerHeight="0dip" />
<TextView
android:id="#+id/empty"
android:layout_width="match_parent"
android:layout_height="wrap_content" //change 2
android:gravity="center"
android:text="#string/no_result_text"
android:visibility="gone" />
</LinearLayout>
android:scrollbars="none"
Try putting the above line in your listview in xml.

Categories

Resources