Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 1    Views: 109

immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
11/04/16 05:00 PM (8 years ago)

Having trouble getting a on/off switch to look how I want.

Currently trying to add a on/off button to my maps plugin. The Button will switch between map and list. My current layout code in bt_screen_map <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/containerView" android:background="@android:color/transparent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_width="fill_parent" > <Switch android:text="" android:id="@+id/switch1" android:background="@android:color/transparent" android:layout_width="match_parent" android:layout_height="wrap_content" android:textOn="@string/capital_on" android:textOff="@string/capital_off" android:checked="true" android:padding="0dp" android:gravity="center"/> <fragment android:id="@+id/mapView" android:name="com.google.android.gms.maps.MapFragment" android:layout_height="0dp" android:layout_width="match_parent" android:layout_weight="1" /> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adSize="SMART_BANNER" ads:adUnitId="@string/banner_ad_unit_id"> </com.google.android.gms.ads.AdView> </LinearLayout> The Switch is displayed but i can't remove the white background Id also like the off switch to be blue like the on switch http://pheds.com.au/speedcamera-new/ss2.png
 
immacul8 apps
Aspiring developer
Profile
Posts: 58
Reg: Sep 10, 2012
adelaide
580
like
11/05/16 05:39 PM (8 years ago)
I've decided to go with a different approach using radio buttons <RadioGroup android:checkedButton="@+id/offer" android:id="@+id/toggle" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginLeft="1dp" android:layout_marginRight="0dp" android:background="@drawable/blue_out_line" android:orientation="horizontal"> <RadioButton android:layout_marginTop="0dp" android:layout_marginBottom="1dp" android:layout_marginLeft="1dp" android:id="@+id/search" android:background="@drawable/toggle_widget_background" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:gravity="center" android:text="@string/capital_off" android:textColor="@color/white" android:textAppearance="?android:attr/textAppearanceMedium"/> <RadioButton android:layout_marginRight="0dp" android:layout_marginTop="1dp" android:layout_marginBottom="1dp" android:id="@+id/offer" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/toggle_widget_background" android:button="@null" android:gravity="center" android:text="@string/capital_on" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/white" /> </RadioGroup> and creating new xml in drawable to control the layout <?xml version="1.0" encoding="UTF-8" standalone="no"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/myblue" android:state_checked="true" /> <item android:drawable="@color/myblue" android:state_pressed="true" /> <item android:drawable="@color/sysTransparent" /> </selector> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/sysLtGray" /> <stroke android:width="2dp" android:color="@color/myblue" /> </shape> http://pheds.com.au/speedcamera-new/ss3.png
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.