Add Scrollview And Highlight On A Linear Layout In Android
I have Linearlayout that have have multiple linear layouts in which one of the main layout have a LinearLayout and Listview. LinearLayout contains multiple ImageView and TextView n
Solution 1:
I hope this will work for u :
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><LinearLayoutandroid:id ="@+id/mainFilterLayout"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><ImageViewandroid:id="@+id/companyLogo"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight=".1"android:layout_gravity="left"android:adjustViewBounds="true"android:background="@mipmap/ic_launcher" /><Viewandroid:clickable="true"android:layout_gravity="center"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1" /><Buttonandroid:id="@+id/btnClear"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="right|center"android:gravity="right|center"android:text="Clear" /><Buttonandroid:id="@+id/btnApply"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="right|center"android:gravity="right|center"android:text="Apply" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"><ScrollViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="2"android:orientation="vertical"><LinearLayoutandroid:id="@+id/brandLayout"android:layout_width="match_parent"android:layout_height="70dp"android:orientation="vertical"><ImageViewandroid:id="@+id/mobbrand"android:layout_width="90dp"android:layout_height="50dp"android:background="@mipmap/ic_launcher"android:layout_gravity="center" /><TextViewandroid:id="@+id/txtBrand"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"android:text="Brand" /></LinearLayout><LinearLayoutandroid:id="@+id/colorLayout"android:layout_width="match_parent"android:layout_height="70dp"android:orientation="vertical"><ImageViewandroid:id="@+id/mobColor"android:layout_width="90dp"android:layout_height="50dp"android:background="@mipmap/ic_launcher"android:layout_gravity="center" /><TextViewandroid:id="@+id/txtColor"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"android:text="COLOUR" /></LinearLayout><LinearLayoutandroid:id="@+id/sizeLayout"android:layout_width="match_parent"android:layout_height="70dp"android:orientation="vertical"><ImageViewandroid:id="@+id/mobSize"android:layout_width="90dp"android:layout_height="50dp"android:background="@mipmap/ic_launcher"android:layout_gravity="center" /><TextViewandroid:id="@+id/txtSize"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"android:text="Size" /></LinearLayout><LinearLayoutandroid:id="@+id/offerLayout"android:layout_width="match_parent"android:layout_height="70dp"android:orientation="vertical"><ImageViewandroid:id="@+id/mobOffers"android:layout_width="90dp"android:layout_height="50dp"android:layout_gravity="center"android:background="@mipmap/ic_launcher" /><TextViewandroid:id="@+id/txtPrice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"android:text="Price" /></LinearLayout><LinearLayoutandroid:id="@+id/othersLayout"android:layout_width="match_parent"android:layout_height="70dp"android:orientation="vertical"><ImageViewandroid:id="@+id/mobother"android:layout_width="90dp"android:layout_height="50dp"android:layout_gravity="center"android:background="@mipmap/ic_launcher" /><TextViewandroid:id="@+id/txtOther"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:gravity="center"android:text="OTHER" /></LinearLayout></LinearLayout></ScrollView><ListViewandroid:id="@+id/subCategory"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="5"android:cacheColorHint="@android:color/transparent"android:divider="#fff"android:dividerHeight="1dp"android:fadingEdge="none"></ListView></LinearLayout></LinearLayout></LinearLayout>
Solution 2:
Simply do one thing cut the amount of code that you want in scrollview.... Now add scrollview in place of the code that u just "cut" ... now scrollview also have a child layout as linear layout.... in that linear layout make height to be wrap_content..... next place your code inside that linear layout... ListView outside the scrollayout...
[code]--------- Ctrl+X
replace with
<ScrollView><LinearLayout>
[code]-------- Ctrl+V
enter code here
</LinearLayout></ScrollView><ListView> -------- here add listview
Post a Comment for "Add Scrollview And Highlight On A Linear Layout In Android"