I am working on an Android application in which I have a RatingBar. Currently for testing, I am setting its value randomly between 1-5. For some reason, the rating bar is always starting from center, and is never occupying the complete space available. Here is how it looks in the app :
The entire space left of rating bar is what I have given in XML, but it's not getting filled.
One other problem with Rating bar is, how can I add a text to left of the RatingBar. Something like Text...(XXXXX). Thank you
Code :
<RatingBar
android:layout_width="135dp"
android:layout_height="40dp"
android:id="#+id/productStars"
android:numStars="5"
android:scaleX="0.3"
android:scaleY="0.3"
android:stepSize="1"
android:layout_alignWithParentIfMissing="false"
android:paddingLeft="20dp"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/description"
android:layout_alignEnd="#+id/description" />
Update
Entire layout :
<?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="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
android:padding="5dip"
android:background="#color/common_action_bar_splitter"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
>
<ImageView
android:layout_width="150dp"
android:layout_height="200dp"
android:id="#+id/productImage"
android:background="#drawable/layout_image"
/>
<TextView
android:id="#+id/comments"
android:layout_width="50dp"
android:layout_height="35dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/abc_input_method_navigation_guard"
android:gravity="left"
android:singleLine="true"
android:layout_marginStart="4dp"
android:layout_marginLeft="4dp"
android:layout_above="#+id/productStars"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignLeft="#+id/description"
android:layout_alignStart="#+id/description" />
<TextView
android:id="#+id/productName"
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="left"
android:scrollHorizontally="true"
android:visibility="visible"
android:layout_toEndOf="#+id/productImage"
android:layout_toRightOf="#+id/productImage"
android:textColor="#color/abc_input_method_navigation_guard"
android:typeface="monospace"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:singleLine="true"
/>
<TextView
android:id="#+id/description"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal|top"
android:ellipsize="end"
android:singleLine="true"
android:gravity="left"
android:scrollHorizontally="true"
android:visibility="visible"
android:layout_above="#+id/comments"
android:layout_toEndOf="#+id/productImage"
android:layout_below="#+id/productName"
android:layout_toRightOf="#+id/productImage"
android:textColor="#color/abc_input_method_navigation_guard"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="3dp"
android:layout_marginEnd="3dp" />
<RatingBar
android:layout_width="135dp"
android:layout_height="40dp"
android:id="#+id/productStars"
android:numStars="5"
android:scaleX="0.3"
android:scaleY="0.3"
android:stepSize="1"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/description"
android:layout_alignEnd="#+id/description" />
<ImageButton
android:layout_width="45dp"
android:layout_height="45dp"
android:id="#+id/swapButton"
android:src="#drawable/swappossible"
android:background="#null"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="#+id/productStars"
android:layout_toStartOf="#+id/productStars" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
Try to replace your rating bar with this
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/productStars"
android:stepSize="1"
android:numStars="5"
style="?android:attr/ratingBarStyleSmall"
android:layout_alignRight="#+id/description"
android:layout_alignEnd="#+id/description" />
Don't give fix width to rating bar, keep it wrap_content. To make rating bar smaller use this instead
style="?android:attr/ratingBarStyleSmall"
Add this to your rating bar
According to your code it should be like this
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/productStars"
android:numStars="5"
style="?android:attr/ratingBarStyleSmall"
android:stepSize="1"
android:layout_alignWithParentIfMissing="false"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/description"
android:layout_alignEnd="#+id/description"
android:layout_gravity="center"/>
Make height wrap_content too and remove scaleX and scaleY too
Related
I am using relative layout in linear layout.My banner appears on the design screen, but no ads appear when I run my application.I looked at many examples but I could not find.My application was horizontal before now I'm designing vertically.Previously I was using Relativelayout then my banner was working.Here my code;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:weightSum="12"
android:background="#fffdd0">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="2">
<RelativeLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true">
<Button
android:id="#+id/btn_double"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:background="#drawable/xx"
android:layout_marginTop="15dp"/>
<Button
android:id="#+id/btn_yariyariya"
android:layout_width="47dp"
android:layout_height="47dp"
android:background="#drawable/fiftyfifty"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"/>
<Button
android:id="#+id/btn_skip"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentEnd="true"
android:background="#drawable/skip"
android:layout_marginTop="15dp"/>
<TextView
android:id="#+id/tv_countdown2x"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_alignParentStart="true"
android:textColor="#color/colorPrimary"
android:layout_below="#+id/btn_double" />
<TextView
android:id="#+id/tv_countdown50"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_centerHorizontal="true"
android:textColor="#color/colorPrimary"
android:layout_below="#+id/btn_yariyariya"/>
<TextView
android:id="#+id/tv_countdownNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_alignParentEnd="true"
android:textColor="#color/colorPrimary"
android:layout_below="#+id/btn_skip"/>
<TextView
android:id="#+id/tv_countdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="00:30"
android:textSize="30sp"
android:layout_centerHorizontal="true"
android:textColor="#color/colorPrimary"
android:layout_marginTop="85dp" />
<FrameLayout
android:id="#+id/container_pop_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp" />
</RelativeLayout>
<TextView
android:id="#+id/tv_countdown1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:layout_marginStart="40dp"
android:layout_marginTop="60dp"
android:textColor="#color/colorPrimary"/>
<Button
android:id="#+id/btn_kalp1"
android:layout_width="50dp"
android:layout_height="40dp"
android:background="#drawable/kalp"
android:layout_alignParentStart="true"
android:layout_marginStart="30dp"
android:layout_marginTop="15dp"/>
<Button
android:id="#+id/btn_satinal"
android:layout_width="50dp"
android:layout_height="40dp"
android:layout_marginStart="200dp"
android:onClick="satinalMain"
android:background="#drawable/satinal"
android:layout_alignParentEnd="true"
android:layout_marginEnd="30dp"
android:layout_marginTop="15dp"/>
<TextView
android:id="#+id/tv_kalp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="5"
android:textColor="#color/colorPrimary"
android:layout_alignParentStart="true"
android:layout_marginTop="25dp"
android:layout_marginStart="84dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:text="X"
android:textColor="#color/colorPrimary"
android:layout_alignParentStart="true"
android:layout_marginTop="35dp"
android:layout_marginStart="77dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="3">
<TextView
android:id="#+id/tv_soru"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:fontFamily="#font/incee"
android:gravity="center"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:textAlignment="gravity"
android:textSize="18sp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="5"
android:orientation="vertical">
<Button
android:id="#+id/btn_a"
android:layout_width="260dp"
android:layout_height="60dp"
android:textColor="#000"
android:background="#drawable/gradient"
android:gravity="center"
android:textAlignment="gravity"
android:fontFamily="#font/incee"
android:textSize="12sp"
android:layout_centerHorizontal="true"/>
<Button
android:id="#+id/btn_b"
android:layout_width="260dp"
android:layout_height="60dp"
android:layout_below="#+id/btn_a"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="#drawable/gradient"
android:fontFamily="#font/incee"
android:gravity="center"
android:textAlignment="gravity"
android:textColor="#000"
android:textSize="12sp" />
<Button
android:id="#+id/btn_c"
android:layout_width="260dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:background="#drawable/gradient"
android:fontFamily="#font/incee"
android:gravity="center"
android:textAlignment="gravity"
android:textColor="#000"
android:textSize="12sp"
android:layout_below="#+id/btn_b"
android:layout_marginTop="5dp"/>
<Button
android:id="#+id/btn_d"
android:layout_width="260dp"
android:layout_height="60dp"
android:textColor="#000"
android:background="#drawable/gradient"
android:gravity="center"
android:textAlignment="gravity"
android:fontFamily="#font/incee"
android:textSize="12sp"
android:layout_below="#+id/btn_c"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"/>
<Button
android:id="#+id/btn_infoA"
android:layout_width="40dp"
android:layout_height="45dp"
android:background="#drawable/info"
android:layout_centerVertical="true"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
<Button
android:id="#+id/btn_gec"
android:layout_width="65dp"
android:layout_height="60dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="1dp"
android:background="#drawable/next"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<TextView
android:id="#+id/tv_skor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:text="0"
android:textColor="#000"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="25dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textStyle="bold"
android:text="SKOR :"
android:textColor="#000"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="50dp"
android:layout_marginBottom="5dp"/>
<Button
android:id="#+id/btn_reklam"
android:layout_width="50dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="5dp"
android:background="#drawable/plus"
android:onClick="startVideoAd"/>
<TextView
android:id="#+id/tv_kalp_kazan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="İzle Kazan"
android:layout_alignParentStart="true"
android:textSize="15sp"
android:textStyle="bold"
android:layout_alignParentBottom="true"
android:fontFamily="#font/incee"
android:textColor="#000"
android:layout_marginStart="55dp"
android:layout_marginBottom="5dp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3101578796185185/4912585915">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
I think it's because the bannerview is lower than your screen! (Maybe you're using this layout for a fragment and your activity has a toolbar, am I right?)
Just put LinearLayout inside a ScrollView and see if it works.
Your layout design is not very well done, the buttons at the center (first RelativeLayout) are not constrained to the adjacent buttons, so they may overlap.
You should use a ConstraintLayout instead of RelativeLayout, the later is obsolete now.
You have several items with wrap_content height inside a layout that you want to stretch vertically, which is contradictory. This may cause views inside the inner RelativeLayouts to be hidden if they are smaller than the height.
weightSum is a property that is rarely useful because weights are calculated automatically, you should simply know that two views with 1 and 1 with use 50% each, and if you add another with weight 2 it will have proportionally that weight. So it will end up 25%, 25% and 50%.
There is no need to place the AdView inside a RelativeLayout if it is the only view there.
If you want the banner to be always visible, then simply place a default height (either wrap_content or a given height in dps). The other views will use the remaining space to calculate the weight space.
I recommend you to first study how different Layouts work before attempting to build your screen layout.
On the other hand, the AdView requires some additional configuration on your end to become shown, because if you did not setup some campaign to be shown, the view won't display anything.
I have recycleView in my project . I have a imageview (handle like action), while i want to like my post it click and when I want to dislike my post , Just my first item click .
I change haight of my item to match parent, it works for the rest of items . But my view is match parent and appearance of layout is not good.
here is my xml :
<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:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
>
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="false"
android:maxHeight="160dp"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
android:layout_height="180dp"
android:background="#drawable/gradient_background" />
<TextView
android:id="#+id/post_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:ellipsize="marquee"
android:gravity="right"
android:maxLines="2"
android:paddingBottom="4dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:shadowColor="#color/text_shadow"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:textColor="#color/white"
android:textSize="18sp"
tools:text="Title" />
<TextView
android:id="#+id/post_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/post_title"
android:paddingBottom="4dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:shadowColor="#color/text_shadow"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="14sp"
tools:text="Hello World" />
<ProgressBar
android:id="#+id/progress"
style="#android:style/Widget.DeviceDefault.Light.ProgressBar.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="visible"
tools:visibility="visible" />
<LinearLayout
android:id="#+id/actions_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/imageView"
android:layout_alignParentRight="true"
android:gravity="start"
android:orientation="horizontal">
<ImageView
android:id="#+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="16dp"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_share" />
<ImageView
android:id="#+id/like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="16dp"
/>
</LinearLayout>
</RelativeLayout>
If I put wrap_content ,it doesn't work correct and just first item is clickable.
Any idea?
In adapter view, you should always keep width as wrap_content. If still you require width to be match_parent, please post your question in understandable words.
I've tried everything I can think of but can't get this layout working. It's a ListView that list matches in a row.
Row one is first match, and next row is second match, and so on. I don't don't mind the green strokes and borders.
Is it even possible?
See the deisgn here:
Here's an example implementation, it does however use negative margins, to overlap the thing I called badge.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cdcdcd"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/score"
android:layout_below="#+id/badge"
android:background="#color/white"
android:orientation="vertical"
android:padding="16dp"
android:showDividers="middle">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 2"/>
</LinearLayout>
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="16dp"
android:text="0 vs 7"
android:layout_below="#+id/badge"
android:textSize="32sp"
android:textStyle="bold"/>
<LinearLayout
android:layout_below="#+id/badge"
android:id="#+id/right_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/score"
android:background="#color/white"
android:orientation="vertical"
android:padding="16dp"
android:showDividers="middle">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 2"/>
</LinearLayout>
<TextView
android:id="#+id/badge"
android:layout_toRightOf="#id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#0f0"
android:layout_marginLeft="-12dp"
android:layout_marginBottom="-8dp"
android:text="Badge"
/>
</RelativeLayout>
To alternate the background simply set the background in getView in your adapter.
You'll need a custom adapter that fills the ListView (better use RecyclerView & an Adapter with ViehHolder), this row layout is taken from my own project, not exactly what you requested, but you'll get the idea. Just comment for further information.
<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="wrap_content"
>
<TextView
android:id="#+id/textV_player1"
android:text="player1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:layout_marginEnd="40dp"
android:textSize="20sp"
android:paddingTop="15dp"
android:gravity="end"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/textV_vs"
android:layout_toStartOf="#+id/textV_vs" />
<TextView
android:id="#+id/textV_player2"
android:text="player2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingTop="15dp"
android:layout_alignBottom="#+id/textV_vs"
android:layout_toRightOf="#+id/textV_vs"
android:layout_toEndOf="#+id/textV_vs" />
<TextView
android:id="#+id/textV_vs"
android:text="vs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="40dp"
android:layout_marginEnd="40dp"
android:textSize="20sp"
android:layout_above="#+id/textV_points1"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/textV_points1"
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingTop="3dp"
android:paddingBottom="15dp"
android:layout_below="#+id/textV_player1"
android:layout_alignRight="#+id/textV_player1"
android:layout_alignEnd="#+id/textV_player1" />
<TextView
android:id="#+id/textV_points2"
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingTop="3dp"
android:paddingBottom="15dp"
android:layout_below="#+id/textV_player2"
android:layout_alignLeft="#+id/textV_player2"
android:layout_alignStart="#+id/textV_player2" />
<TextView
android:id="#+id/textV_vspoints"
android:text=":"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:paddingBottom="15dp"
android:layout_below="#id/textV_vs"
android:layout_centerHorizontal="true" />
</RelativeLayout>
I want to change text of Textview dynamically,
but it does not show full text.instead it shw one or two character less than it or sometimes show "...." atlast.
This is a layout for an custom equalizer.
This is my xml file.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/fullscreenlnearlayout"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.38"
android:gravity="center" >
<Button
android:id="#+id/btnformenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="Create New..." />
<ImageButton
android:id="#+id/refresh"
android:contentDescription="Reset Equalizer to Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_margin="20dp"
android:adjustViewBounds="false"
android:alpha=".4"
android:src="#drawable/refresh"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ToggleButton
android:id="#+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/refresh"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:alpha=".4" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:id="#+id/horizontalscrollforequaliser"
android:layout_height="0dp"
android:isScrollContainer="false"
android:layout_weight="1">
<TextView
android:id="#+id/seekbar1kabottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="60Hz" />
<include
android:id="#+id/include5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/seekbar1kabottom"
android:layout_alignTop="#+id/include7"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
layout="#layout/eq_bar" />
<TextView
android:id="#+id/seekbar3katop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:singleLine="true"
android:text="0mB" />
<TextView
android:id="#+id/seekbar3kabottom"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_centerInParent="true"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="910Hz" />
<include
android:id="#+id/include7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/seekbar3kabottom"
android:layout_alignParentLeft="true"
android:layout_below="#+id/seekbar3katop"
layout="#layout/eq_bar" />
<include
android:id="#+id/include"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/seekbar5kabottom"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/include4"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
layout="#layout/eq_bar" />
<include
android:id="#+id/include4"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/include5"
android:layout_alignTop="#+id/include6"
android:layout_toStartOf="#+id/include"
android:layout_toLeftOf="#+id/include"
layout="#layout/eq_bar" />
<TextView
android:id="#+id/seekbar4katop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/include4"
android:layout_alignStart="#+id/include4"
android:layout_alignEnd="#+id/seekbar4kabottom"
android:layout_alignLeft="#+id/include4"
android:layout_alignRight="#+id/seekbar4kabottom"
android:singleLine="false"
android:text="0mB"/>
<TextView
android:id="#+id/seekbar5kabottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:singleLine="true"
android:layout_below="#+id/include4"
android:text="14KHz" />
<TextView
android:id="#+id/seekbar4kabottom"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/include4"
android:layout_alignLeft="#+id/include4"
android:layout_below="#+id/include4"
android:text="3600Hz" />
<TextView
android:id="#+id/seekbar2kabottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/include6"
android:layout_alignParentBottom="true"
android:singleLine="true"
android:text="230Hz" />
<TextView
android:id="#+id/seekbar2katop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/include6"
android:layout_alignEnd="#+id/seekbar2kabottom"
android:layout_alignLeft="#+id/include6"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/seekbar2kabottom"
android:singleLine="false"
android:text="0mB" />
<include
android:id="#+id/include6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/include7"
android:layout_below="#+id/seekbar1katop"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_toRightOf="#+id/include7"
layout="#layout/eq_bar" />
<TextView
android:id="#+id/seekbar5katop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/include"
android:layout_alignLeft="#+id/seekbar5kabottom"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/include"
android:singleLine="false"
android:text="0mB" />
<TextView
android:id="#+id/seekbar1katop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/include7"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/include7"
android:singleLine="false"
android:text="0mB" />
</RelativeLayout>
</LinearLayout>
In picture you can see text s not coming u fully....it is not showing mB (unit) atlast.
I am trying this from several hours,but unable to do this
Please give me a way to achieve this .
Thans in advance :)
You can decrease the text size of the TextView and see the changes. Ideally Android design guidelines specify that you create separate layouts for different screen sizes and resolutions. So on some devices the TextView font size would just fit fine but for others it'd have to be adjusted
You can decrease Text size of the TextView .
If you want remove .... You can remove this line
android:singleLine="true"
and set width as match_parent or fill_parent .
Remove wrap content and set a size using dp, it will probably work
I have this image(#drawable/engines_bg), as my Horizontal Scroll view:
you can see the triangle is in the exact middle.
However, when I run my Activity, the triangle is closed to the left:
(if you measure with a roller)
how can it be?
I have checked and there is no re-positioning in the code.
here is my xml:
<com.w.view.title.TitleBar
android:id="#+id/titleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ListView
android:id="#+id/searchResultsList"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="#+id/searchButtonBar"
android:layout_below="#id/titleBar"
android:cacheColorHint="#00000000"
android:divider="#null"
android:fadingEdge="none"
android:scrollbars="none" />
<com.w.navigate.SearchButtonsBarHorizontalScrollView
android:id="#+id/searchButtonBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/engines_bg"
android:fadingEdge="horizontal"
android:gravity="center"
android:padding="0dp"
android:scrollbars="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="25dp" >
<ImageButton
android:id="#+id/leftMargin"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:visibility="invisible" />
<ImageButton
android:id="#+id/searchButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/searchButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/rightMargin"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:visibility="invisible" />
</LinearLayout>
</com.w.navigate.SearchButtonsBarHorizontalScrollView>
<LinearLayout
android:id="#+id/searchProgressPopup"
android:layout_width="180dp"
android:layout_height="140dp"
android:layout_centerInParent="true"
android:background="#drawable/semi_transparent_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="invisible" >
<com.w.view.map.ProgressAnimation
android:id="#+id/searchProgressAnimation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1" />
<TextView
android:id="#+id/searchProgressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:gravity="center"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="6dp"
android:layout_below="#id/titleBar"
android:scaleType="fitXY"
android:src="#drawable/topbar_shadow" />
update:
I have tried #Brian's solution, but it's all mixed up:
<com.w.view.title.TitleBar
android:id="#+id/titleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ListView
android:id="#+id/searchResultsList"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="#+id/searchButtonBarWrapper"
android:layout_below="#id/titleBar"
android:cacheColorHint="#00000000"
android:divider="#null"
android:fadingEdge="none"
android:scrollbars="none" />
<LinearLayout
android:id="#+id/searchButtonBarWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/engines_bg"
android:orientation="horizontal" >
<com.w.navigate.SearchButtonsBarHorizontalScrollView
android:id="#+id/searchButtonBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadingEdge="horizontal"
android:gravity="center"
android:padding="0dp"
android:scrollbars="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="25dp" >
<ImageButton
android:id="#+id/leftMargin"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:visibility="invisible" />
<ImageButton
android:id="#+id/searchButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/searchButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/searchButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/searchButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/searchButton5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:onClick="engineClicked" />
<ImageButton
android:id="#+id/rightMargin"
android:layout_width="160dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/search_engine_button"
android:visibility="invisible" />
</LinearLayout>
</com.w.navigate.SearchButtonsBarHorizontalScrollView>
</LinearLayout>
<LinearLayout
android:id="#+id/searchProgressPopup"
android:layout_width="180dp"
android:layout_height="140dp"
android:layout_centerInParent="true"
android:background="#drawable/semi_transparent_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="invisible" >
<com.w.view.map.ProgressAnimation
android:id="#+id/searchProgressAnimation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1" />
<TextView
android:id="#+id/searchProgressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:gravity="center"
android:textColor="#FFFFFF" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="6dp"
android:layout_below="#id/titleBar"
android:scaleType="fitXY"
android:src="#drawable/topbar_shadow" />
The result:
Uapdte2: Tried Luksprog's 9.png
I had two problems:
1) the 1 pixel dots are visible
2) the arrow is to strached
3) I sae the original 9.png in two folders. How can I know which one my device relates to?
Your nine patch image is too big to be handled by the ScrollView so the arrow doesn't get in the middle where you'd want it. So make the nine patch image smaller in width(that would be one of the advantages of nine patches vs regular images) by simply taking out two equal chunks from the left and right of the arrow and also adding the stretch points(which should be equal so the image gets stretched proportionally).
Here's my attempt(which should be saved as the_image_etc.9.png):
If you miss transparency somewhere it may be due to me saving that wrong but the general approach of obtaining the image is above.
I save the original 9.png in two folders. How can I know which one my
device relates to?
When using a nine patch you need to have a version for each of the density drawable folders(so the image itself doesn't get resized using the image from another density folder), you don't need versions for different sizes of the screens(that's what is great about nine patches, they take out the size issue by extending themselves).