Android Programming Linear Layout ArrayList Integers - android

I have an arraylist of integers called numbers. How do I display these numbers horizontally and then vertically with the linear layout widget for my android app?
public class SecondActivity extends AppCompatActivity {
private ArrayList<Integer> Numbers = new ArrayList<Integer>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Numbers.add(1);
Numbers.add(2);
Numbers.add(3);
Numbers.add(4);
Numbers.add(5);
//Linear Layout code goes here
}
}

In case if its mandatory create a custom table with row and column with the proper weight and repeat row wise with linear layout.
if Not mandatory then use table Layout android. it will make your job simpler.
Here I found Some old Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/dms_background" >
<!-- User Details -->
<RelativeLayout
android:id="#+id/report_title_layout"
android:layout_width="fill_parent"
android:layout_height="#dimen/forty_dp"
android:layout_alignParentTop="true"
android:background="#color/dms_actionbar" >
<TextView
android:id="#+id/report_associate_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/retailer_report"
android:textColor="#color/White" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/report_main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/report_title_layout"
android:layout_marginTop="#dimen/five_dp" >
<!-- Table View -->
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="#dimen/ten_dp"
android:shrinkColumns="*"
android:stretchColumns="*" >
<!-- Row 1 -->
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<RelativeLayout
android:id="#+id/report_salesorder_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true" >
<ImageView
android:id="#+id/report_retailt_transaction_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/ic_sales" />
<TextView
android:id="#+id/report_retailt_transaction_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/report_retailt_transaction_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:text="#string/report_salesreport"
android:textColor="#color/White" />
<View
android:layout_width="100dp"
android:layout_height="2dp"
android:layout_below="#id/report_retailt_transaction_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/devider_horizontal" />
<View
android:layout_width="2dp"
android:layout_height="#dimen/ninty_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/devider_vertical" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/report_salesreturn_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true" >
<ImageView
android:id="#+id/report_partner_search_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/ic_return" />
<TextView
android:id="#+id/report_partner_search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/report_partner_search_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:text="#string/report_returnreport"
android:textColor="#color/White" />
<View
android:layout_width="100dp"
android:layout_height="2dp"
android:layout_below="#id/report_partner_search_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/devider_horizontal" />
</RelativeLayout>
</TableRow>
<!-- Row 2 -->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<RelativeLayout
android:id="#+id/report_paymentcollection_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true" >
<ImageView
android:id="#+id/report_route_plan_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/ic_payment" />
<TextView
android:id="#+id/report_route_plan_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/report_route_plan_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:text="#string/report_payreport"
android:textColor="#color/White" />
<View
android:layout_width="100dp"
android:layout_height="2dp"
android:layout_below="#id/report_route_plan_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/devider_horizontal" />
<View
android:layout_width="2dp"
android:layout_height="#dimen/ninty_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/devider_vertical" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/report_performance_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true" >
<ImageView
android:id="#+id/report_new_partner_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/ic_performance" />
<TextView
android:id="#+id/report_new_partner_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/report_new_partner_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:text="#string/report_performancereport"
android:textColor="#color/White" />
<View
android:layout_width="100dp"
android:layout_height="2dp"
android:layout_below="#id/report_new_partner_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/devider_horizontal" />
</RelativeLayout>
</TableRow>
<!-- Row 3 with 2 columns -->
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<RelativeLayout
android:id="#+id/report_stock_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true" >
<ImageView
android:id="#+id/report_report_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/ic_stock" />
<TextView
android:id="#+id/report_report_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/report_report_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:text="#string/report_stockreport"
android:textColor="#color/White" />
<View
android:layout_width="100dp"
android:layout_height="2dp"
android:layout_below="#id/report_report_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/devider_horizontal" />
<View
android:layout_width="2dp"
android:layout_height="#dimen/ninty_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/devider_vertical" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/report_report_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true" >
<ImageView
android:id="#+id/report_empty_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="invisible"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/ic_reportsasso" />
<TextView
android:id="#+id/report_empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/report_empty_image"
android:layout_centerHorizontal="true"
android:visibility="invisible"
android:layout_marginTop="#dimen/ten_dp"
android:text="#string/associate_reports"
android:textColor="#color/White" />
<View
android:layout_width="100dp"
android:layout_height="2dp"
android:layout_below="#id/report_empty_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/ten_dp"
android:background="#drawable/devider_horizontal"
/>
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
</RelativeLayout>

Related

Fetch imageview to all the screen in relativelayout between buttons and edittext

I have the below XML relativelayout... I need help to make the image always fetch to all the screen but between above name ju and below buttons.
the following ImageView parameter make the image centered.
<?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="match_parent"
android:orientation="vertical" >
<TextView android:id="#+id/nameview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFE0"
android:paddingBottom="10dp"
android:paddingTop="14dp"
android:paddingLeft="45dp"
android:fontFamily="Arial"
android:textSize="18sp"
android:textStyle="bold"
android:text="Ju" />
<ImageView android:id="#+id/SingleView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/nameview"/>
<Button
android:id="#+id/funnyBtn"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_below="#+id/SingleView"
android:layout_alignParentLeft="true"
android:src="#drawable/smileclk"
android:background="#drawable/smileclk"
android:layout_marginLeft="25dp"
android:text="" />
<Button
android:id="#+id/test1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/SingleView"
android:layout_toRightOf="#+id/funnyBtn"
android:layout_marginLeft="15dp"
android:text="test1" />
<Button
android:id="#+id/test2Btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/SingleView"
android:layout_toRightOf="#+id/comment"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:text="test2" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="20dp"
android:layout_below="#+id/test2Btn"
android:background="#ff00ff00" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="20dp"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculation" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ffffff" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
this is my result for now
this is my desire output
As murtaza mentioned adding android:scaleType="fitXY" helped
<ImageView android:id="#+id/SingleView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:layout_below="#id/nameview"/>

Separator does not show in relative layout

I have a view as shown below. There is a separator (vertical divider) before imageview. I can see the separator on graphical layout, but when I run the code, separator is not shown on emulator and phone.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/product_list_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
android:padding="0sp" >
<RelativeLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5sp" >
<TextView
android:id="#+id/product_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toStartOf="#+id/product_price"
android:layout_toLeftOf="#+id/product_price"
android:text="product_name"
android:layout_centerVertical="true"
android:textColor="#2c3e50"
android:textSize="15sp"/>
<TextView
android:id="#+id/product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toStartOf="#+id/seperator"
android:layout_toLeftOf="#+id/seperator"
android:text="525 manat"
android:layout_centerVertical="true"
android:textColor="#34495e"
android:textSize="15sp"
android:layout_marginEnd="10sp"
android:layout_marginLeft="10sp"
android:layout_marginRight="5sp"
android:layout_marginStart="5sp"/>
<View
android:id="#+id/seperator"
android:layout_width="2sp"
android:layout_height="match_parent"
android:layout_toStartOf="#+id/addCartBtn"
android:layout_toLeftOf="#+id/addCartBtn"
android:layout_alignParentTop="true"
android:layout_marginEnd="2sp"
android:layout_marginStart="2sp"
android:layout_marginLeft="2sp"
android:layout_marginRight="2sp"
android:background="#9a9d9f" />
<ImageView
android:id="#+id/addCartBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="3sp"
android:layout_marginRight="3sp"
android:background="#FFFFFF"
android:focusable="false"
android:focusableInTouchMode="false"
android:src="#drawable/addcart" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#767e84" />
</LinearLayout>

TextView is not updated within RelativeLayout

I'm developing a custom camera app. CameraPreview takes a part of the screen, and the rest of the screen on the rightis allocated for control panel.
Now, when I change the shooting parameters, the text view and toggle views on the control panels are not updated. I guess this is because of the camera, but I have no clue what to do.
This is a screen shot:
the screen shot with messed textview
My layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="#+id/total_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="#+id/gen_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#AA8888">
<FrameLayout
android:id="#+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>
<RelativeLayout
android:id="#+id/overlay_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/topLeftMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_left_top_corner"
android:tag="mark" />
<ImageView
android:id="#+id/bottomLeftMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_left_bottom_corner"
android:tag="mark" />
<ImageView
android:id="#+id/topRightMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_right_top_corner"
android:tag="mark" />
<ImageView
android:id="#+id/bottomRightMark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/red_right_bottom_corner"
android:tag="mark" />
<ImageView
android:id="#+id/leftCrop"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
<ImageView
android:id="#+id/rightCrop"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
<ImageView
android:id="#+id/upperCrop"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
<ImageView
android:id="#+id/bottomCrop"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:scaleType="fitXY"
android:src="#drawable/rect_60_trasparent" />
</RelativeLayout>
</FrameLayout> <!-- GEN_VIEW END -->
<RelativeLayout
android:id="#+id/whparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true">
<include layout="#layout/wheel_panel"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/adLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="bottom"
android:layout_toLeftOf="#id/whparent"
android:layout_alignTop="#id/whparent"
>
</RelativeLayout>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#id/whparent"
android:layout_margin="10dp"
android:text="#string/hello"
android:textSize="14sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/control_panel"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:id="#+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="Pocket Viewfinder" />
<TextView
android:id="#+id/viewAngle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/hello"
android:textSize="10sp" />
<TextView
android:id="#+id/widerWarning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/wWarning"
android:textColor="#color/warning_color"
android:textSize="10sp"
android:visibility="invisible" />
<Button
android:id="#+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="#string/capture_button" />
<ToggleButton
android:id="#+id/booster_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textOff="#string/booster_off"
android:textOn="#string/booster_on" />
</LinearLayout>
</RelativeLayout> <!-- TOTAL_VIEW END -->
</RelativeLayout>
Everytime the TextView text is changed, I call:
controlPanelView.requestLayout();
But the controlPanelView is not updated at all.
What am I doing wrong? THNX

ScrollView not works on Relative Layout

I am trying to make my layout Scrollable by adding ScrollView as an parent for my Relative Layout.But my layout not scrolled.I have added the fillport property to true.
Here is my xml file:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/repActivityTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ellipsize="middle"
android:textSize="18sp"
android:background="#android:color/darker_gray"
android:text="#string/representativeTitle" />
<TextView
android:id="#+id/repStreet"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/repImage"
android:layout_marginTop="14sp"
android:layout_toRightOf="#+id/repImage"
android:layout_margin="3sp"
android:text="#string/repStreet" />
<TextView
android:id="#+id/repState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/repStreet"
android:layout_toRightOf="#+id/repImage"
android:text="#string/repState" />
<TextView
android:id="#+id/repCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/repState"
android:layout_below="#+id/repState"
android:text="#string/repCountry" />
<com.google.android.maps.MapView
android:id="#+id/repMap"
android:layout_width="100dip"
android:layout_height="100dip"
android:paddingTop="2dp"
android:layout_marginTop="2dp"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/repImage"
android:apiKey="0lsQmtr2D241pSL53j0vQ2lYUs4_ZIWkIHyHAKw" >
</com.google.android.maps.MapView>
<View
android:id="#+id/firstHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/repMap"
android:layout_marginTop="54dp"
android:background="#android:color/black" />
<TextView
android:id="#+id/issues2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/issues1"
android:layout_centerVertical="true"
android:text="#string/issues2" />
<View
android:id="#+id/secondHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/accomplishments"
android:background="#android:color/black" />
<TextView
android:id="#+id/issues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignBottom="#+id/firstHorizontalLine"
android:layout_alignRight="#+id/repStreet"
android:text="#string/issues" />
<TextView
android:id="#+id/accomplish2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/accomplish1"
android:layout_below="#+id/accomplish1"
android:layout_marginTop="18dp"
android:text="#string/accomplishments2" />
<TextView
android:id="#+id/promises"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/issues"
android:gravity="center"
android:layout_below="#+id/accomplish2"
android:text="#string/promises" />
<View
android:id="#+id/thirdHorizontalLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black"
android:layout_alignParentLeft="true"
android:layout_below="#+id/promises" />
<TextView
android:id="#+id/accomplishments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/issues2"
android:gravity="center"
android:layout_toLeftOf="#+id/repMap"
android:text="#string/accomplishments" />
<TextView
android:id="#+id/accomplish1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/secondHorizontalLine"
android:layout_marginTop="21dp"
android:text="#string/accomplishments1" />
<TextView
android:id="#+id/issues1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/issues2"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="#string/issues1" />
<ImageView
android:id="#+id/repImage"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_alignParentLeft="true"
android:layout_below="#+id/repActivityTitle"
android:contentDescription="#string/representativeImage"
android:paddingTop="2dp"
android:layout_marginTop="2dp"
android:scaleType="centerCrop"
android:src="#drawable/icon" />
<TextView
android:id="#+id/promise1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/thirdHorizontalLine"
android:layout_marginTop="19dp"
android:text="#string/promises1" />
<TextView
android:id="#+id/promise2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/promise1"
android:text="#string/promises2" />
</RelativeLayout>
</ScrollView>
Here I have used the ScrollView but the full content of layout is not as showing.As scrolls not work here.
Try to remove this line and check
android:fillViewport="true"
And also you can try height of relativelayout to match_parent instead of wrap_content
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>

Huge calls made to ViewRoot.draw()

I have an activity which has some text views and other data to be updated every second.
The performance is sluggish and when i capture the logs and view in TraceView.
I see at lot of calls been made to ViewRoot.draw() function.
25 calls in a short span of 4 seconds, almost 6 calls every sec.
Ideally speaking it should be once call every sec.
As per my initial speculation i beleive it is due to the bad layout of my xml, is this true?
How do i identify what is the reason for so many calls?
which is the best way to reduce these calls?
If these TextViews have their layout_width set to WRAP_CONTENT, then changing the text will trigger a measurement pass as their size will have changed. That could certainly get expensive. Try making them fixed-width.
Please find the layout below,
74 calls is ok but 25 calls are been made to ViewRoot.draw() in about 3.5 seconds
which means 6 calls for draw every second that is bad.
I want to know why so many calls are made ?
<RelativeLayout
android:id="#+id/qd3"
android:layout_height="80px"
android:layout_width="156px"
android:layout_marginTop="4px"
android:layout_marginRight="2px"
android:layout_marginLeft="4px"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/qd2"
android:background="#drawable/btn_hl_vd_land"
android:clickable="true">
<FrameLayout
android:id="#+id/FrameCell3"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<ImageView
android:id="#+id/qd3_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/qd_vd_gloss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gloss_wt_tr_land"
/>
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/qd4"
android:layout_height="80px"
android:layout_width="156px"
android:layout_marginTop="4px"
android:layout_marginRight="2px"
android:layout_marginLeft="4px"
android:layout_below = "#+id/qd3"
android:layout_toRightOf="#+id/qd1"
android:background="#drawable/btn_hl_lp_land"
android:clickable="true"
>
<FrameLayout
android:id="#+id/FrameCell4"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<ImageView android:id="#+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_wt_lp_bg_land"></ImageView>
<ImageView android:id="#+id/ImageView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
></ImageView>
<ImageView android:id="#+id/ImageView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_wt_lp_num"></ImageView>
<ImageView
android:id="#+id/qd4_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="#+id/lpCountBig"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="50sp"
android:paddingTop="17px"
android:paddingLeft="65px"
/>
<TextView
android:id="#+id/lpCountSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="38sp"
android:paddingTop="22px"
android:paddingLeft="57px"
/>
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/qd2"
android:layout_height="80px"
android:layout_width="156px"
android:layout_marginTop="4px"
android:layout_marginLeft="2px"
android:layout_toRightOf = "#+id/qd1"
android:layout_alignParentLeft="true"
android:background="#drawable/btn_hl_qd2_land"
android:clickable="true">
<FrameLayout
android:id="#+id/FrameCell4"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
<ImageView
android:id="#+id/qd_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/divider_wt_qd_land"
/>
<ImageView
android:id="#+id/qd_time_gloss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gloss_wt_tl_land"
/>
</FrameLayout>
<RelativeLayout
android:id="#+id/qd_time"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/mDataOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="#000000"
android:textSize="44sp"
android:layout_alignParentRight="true"
android:paddingRight="8px"
android:paddingTop="2px"
/>
<TextView
android:id="#+id/mDataFive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="#000000"
android:textSize="44sp"
android:layout_alignParentRight="true"
android:paddingRight="8px"
android:paddingTop="2px"
/>
<TextView
android:id="#+id/mDataSeven"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="#000000"
android:textSize="44sp"
android:layout_alignParentRight="true"
android:paddingRight="8px"
android:paddingTop="2px"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/qd_pc_sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="#+id/mDataTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="#000000"
android:textSize="44sp"
android:layout_alignParentRight="true"
android:paddingTop="43px"
android:paddingRight="8px"
/>
<TextView
android:id="#+id/mutOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_gravity="right"
android:textColor="#000000"
android:layout_alignParentLeft="true"
android:layout_alignBaseline="#+id/mDataTwo"
android:paddingLeft="10px"
/>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/qd1"
android:layout_height="80px"
android:layout_width="156px"
android:layout_marginTop="4px"
android:layout_marginLeft="2px"
android:layout_alignParentLeft="true"
android:layout_below="#+id/qd2"
android:background="#drawable/btn_hl_qd1_port"
android:clickable="true">
<FrameLayout
android:id="#+id/FrameCell1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#drawable/btn_wt_bl_land" >
<ImageView
android:id="#+id/qd1_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/map_signal_sought"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/map_wt_overlay_default_land"
android:clickable="true"/>
<ImageView
android:id="#+id/map_seeking_signal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<ImageView
android:id="#+id/map_gloss"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/gloss_wt_bl_land"
/>
</FrameLayout>
<FrameLayout
android:id="#+id/FrameCellMap"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<ImageView
android:id="#+id/map_gloss"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/gloss_wt_bl_land"
/>
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/qd4_hr"
android:layout_height="80px"
android:layout_width="156px"
android:layout_marginTop="4px"
android:layout_marginRight="2px"
android:layout_marginLeft="4px"
android:layout_below = "#+id/qd3"
android:layout_toRightOf="#+id/qd1"
android:background="#drawable/btn_hl_lp_land"
android:clickable="true"
>
<ImageView
android:id="#+id/qd4_image_z"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="#+id/qd4_image_divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/divider_wt_qd_land"
/>
<FrameLayout
android:id="#+id/FrameCell1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
>
<TextView
android:id="#+id/curzValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="46sp"
android:layout_gravity="right|bottom"
android:paddingRight="8px"
android:layout_marginBottom="32px"
/>
<TextView
android:id="#+id/curzName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="38sp"
android:textStyle="bold"
android:layout_gravity="right|bottom"
android:paddingRight="8px"
/>
</FrameLayout>
<TextView
android:id="#+id/curz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="18sp"
android:text="#string/hr_z_cardio"
android:layout_alignParentBottom="true"
android:paddingLeft="10px"
android:paddingBottom="5px"
/>
<ImageView
android:id="#+id/qd_lp_gloss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gloss_wt_br_land"
/>
<ImageView android:id="#+id/gUpDown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:visibility="invisible"
android:layout_marginBottom="5px"
android:background="#drawable/ic_wt_z_ad_lg"
/>
</RelativeLayout>
<RelativeLayout android:orientation="horizontal"
android:gravity="bottom" android:layout_height="wrap_content"
android:id="#+id/mControls"
android:layout_width="wrap_content">
<include layout="#layout/m" />
</RelativeLayout>
<RelativeLayout android:orientation="horizontal"
android:gravity="bottom" android:layout_height="wrap_content"
android:id="#+id/tWtCons"
android:visibility="invisible"
android:layout_width="wrap_content">
<include layout="#layout/st_wt" />
</RelativeLayout>

Categories

Resources