Item to right Side? - android

I am trying to keep all item to right side I find code in Google but it is not working with me.
latest_lsv_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.apps.newsapplication"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/list_bg"
android:orientation="horizontal" >
<com.example.util.RoundedImageView
android:id="#+id/img_newslistlatest"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_margin="13dp"
android:scaleType="centerCrop"
app:border_color="#color/divider"
app:border_width="8dip"
app:round_background="true" />
<TextView
android:id="#+id/txt_newslistheadinglatest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="0dp"
android:maxLines="3"
android:text=""
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/text_color" />
</LinearLayout>
fragment_lastest.xml
<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="#color/background_color"
android:gravity="center"
android:id="#+id/rootlayout"
android:orientation="vertical" >
<ListView
android:id="#+id/lsv_latest"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="#color/divider"
android:dividerHeight="1dp">
</ListView>
</LinearLayout>
if you want more code or file I will past it here...
activity_main.xml
LastFragment.java
etc...
I try to use RTL but also not working with me

Related

ListView not scrolling.Just Listview

I have tried a lot of things but still not scrolling i added scrollbars even though it was not related. i tried to change focus but still no scrolling.
Here is my code for Contacts_list.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context="Contacts_fragment"
tools:listitem="#layout/fragment_contacts"
android:scrollbars="vertical"
/>
and code for fragment_contacts.xml which is included in above xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="1"
android:gravity="bottom">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/image"
android:contentDescription="#string/Description"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/phone"
android:textSize="14sp"
android:gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/image"
android:layout_toEndOf="#+id/image" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/name"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="top"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/image"
android:layout_toEndOf="#+id/image" />
</RelativeLayout>
This is my complet Code
Use Layout like below xml in Contacts_list.xml and no need to include scroll bar.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</ListView>
<LinearLayout>
Try this xml for listview
<ListView
android:id="#+id/sampleListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:listitem="#layout/fragment_contacts"
>
</ListView>

Why is HorizontalScrollView scrolling to right?

The below XML contains an EditText control. As soon as I touch it, the softkeyboard appears but the HorizontalScrollView scrolls to the right so I cannot see the EditText!
Can somebody please tell me what is wrong with the below XML and why it is doing this?
Please excuse hardcoded widths - this is only a test bit of code for sanity checking.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView
android:id="#+id/testScrollView"
android:layout_width="1280dp"
android:layout_height="match_parent"
android:scrollbars="horizontal"
android:background="#00FF00">
<LinearLayout
android:id="#+id/layout"
android:layout_width="2560dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/mLeftBaseLinearLayout"
android:layout_width="1280dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FF0000">
<EditText
android:id="#+id/mEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#BBBBBB"
android:gravity="center"
android:text="EditText"
android:textColor="#FFFF00"
android:textSize="30dp"
android:singleLine="true"
android:clickable="true"
android:editable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:inputType="text"/>
<ListView
android:id="#+id/mListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#80FFFFFF" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/linLayout"
android:layout_width="1280dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#00FF00">
<Button
android:layout_width="600dp"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:layout_width="600dp"
android:layout_height="wrap_content"
android:text="Button2" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
My tablet is running Android 4.2.1
Ok, I have been looking at your layout and made a few changes and it looks ok on my computer.
Firstly, mEditText is unnecessary and avoidable. If you want a header for mListView
yourListView.addHeaderView(View v, Object data, boolean isSelectable);
This is what I did:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:id="#+id/testScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FF00"
android:scrollbars="horizontal" >
<LinearLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/mLeftBaseLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:orientation="vertical" >
<EditText
android:id="#+id/mEditText"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#BBBBBB"
android:clickable="true"
android:editable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:inputType="text"
android:singleLine="true"
android:text="EditText"
android:textColor="#FFFF00"
android:textSize="30dp" />
<ListView
android:id="#+id/mListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#80FFFFFF" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/linLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FF00"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2" />
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
If this does not work we need to look at your code.
I found my solution - override scrollTo() and do absolutely nothing.

android RelativeLayout below not working

I have main RelativeLayout layout file. I have scrollview and two buttons and listview inside this scrollview.I have one problem , when i run program it show's only one item in listview.my problem is xml file. How i can change my problem?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#5f2585" >
<Button
android:id="#+id/studia"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/n_button"
android:text="სტუდია"
android:textColor="#ffffff" />
<ListView
android:id="#+id/menu_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/studia"
android:divider="#null"
>
</ListView>
<Button
android:id="#+id/gadacema"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/menu_listview"
android:background="#drawable/n_button"
android:text="გადაცემა"
android:textColor="#ffffff" />
</RelativeLayout>
in programmatically everything is ok(if i deleted scrollview,then i can show all values,but i cannot show button witch is a below in listview
What is wrong in my xml file. How can i solve this problem?
Please try this.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#5f2585" >
<Button
android:id="#+id/studia"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/n_button"
android:text="სტუდია"
android:textColor="#ffffff" />
<ListView
android:id="#+id/menu_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/studia"
android:divider="#null"
>
</ListView>
<Button
android:id="#+id/gadacema"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/menu_listview"
android:background="#drawable/n_button"
android:text="გადაცემა"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Try this:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/studia"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#drawable/n_button"
android:text="სტუდია"
android:textColor="#ffffff" />
<ListView
android:id="#+id/menu_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/studia"
android:divider="#null"/>
<Button
android:id="#+id/gadacema"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="#+id/menu_listview"
android:background="#drawable/n_button"
android:text="გადაცემა"
android:textColor="#ffffff" />
</RelativeLayout>

ListView inside tab is not filling height?

I'm using TabHost and inside of one tab, I inserted ListView. I set all height's to fill_parent. But it doesn't show full list, but only part of it. What to do to make tab contents fill screen by height?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bkg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="7dp"
android:background="#drawable/gradientrounded"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:src="#drawable/taxisign" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/taxiprofiletitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_weight="0.9"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
<Button
android:id="#+id/phonenumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:background="#drawable/button"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Button"
android:textColor="#ffffff" />
</LinearLayout>
<ProgressBar
android:id="#+id/loadFeedbacks"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:visibility="invisible" />
</LinearLayout>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFF0000" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:background="#FF000000"
android:layout_height="wrap_content" >
<TextView
android:tag="tab0"
android:text="Инфо"
android:background="#android:drawable/btn_star_big_on"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:tag="tab1"
android:text="Отзывы"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:tag="tab2"
android:text="Тарифы"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</TabWidget>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/profile_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Info" />
</LinearLayout>
<LinearLayout
android:id="#+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView android:text="Добавить"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TextView>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<ListView
android:id="#+id/reviewslist"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="#+id/tariffslist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
</ListView>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
</ScrollView>
On your very first LinearLayout change the layout_height="match_parent". Also, fill_parent has been deprecated since API 8 and replaced with match_parent so that is what you should be using instead.
You have used wrap content for your listView height. You should always use height as match_parent/fill_parent. I guess your problem is here
<ListView
android:id="#+id/reviewslist"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
change it to:
<ListView
android:id="#+id/reviewslist"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
Adding to that, this layout seems to be innefcient. Listviews inside scrollviews are not recommended.
It does seem while quickly viewing the XML file that the parent of your TabHost (LinearLayout) is 'wrap_content' so I am not sure that you are getting all the parents. I do desire a better UI interface for building visuals through Eclipse. Not too happy to work out issues like this when they come up. And they can come up frequently. Usually it involves some trial and error to get things looking the way I want.
Scroll Layout was unnecessary, removing it, made code to work

show multiple rows of HorizontalListView

I am trying to display multiple HorizontalListView in a linearlayout. However, I can only see the firs HorizontalListView. All stuff after that disappeared.
The following is the layout.xml`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical">
<com.devsmart.android.ui.HorizontalListView
android:id="#+id/saladMenuView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ddd"
android:fillViewport="false" />
<com.devsmart.android.ui.HorizontalListView
android:id="#+id/pizzaMenuView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ddd"
android:fillViewport="false" />
</LinearLayout>`
I can always see saladMenuView, but pizzaMenuView never shows up.
Does anyone know why?
I found the reason, i set android:weightSum property.
The following is the my layout.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:orientation="vertical"
android:weightSum="2" >
<TextView
android:id="#+id/show_text_ricerca_ingredienti"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="#string/show_text_ricerca_ingredienti"
android:layout_marginTop="10dp"/>
<com.devsmart.android.ui.HorizontalListView
android:id="#+id/hlistviewIngredienti"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"/>
<TextView
android:id="#+id/show_text_ricerca_per_categorie"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="#string/show_text_ricerca_per_categorie"
android:layout_marginTop="10dp"/>
<com.devsmart.android.ui.HorizontalListView
android:id="#+id/hlistview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true" >
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="buttonNext"
android:text="#string/btn_next"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" />

Categories

Resources