Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

toggleButton on status displays odd graphic [android]

Options
  • 15-10-2013 4:39pm
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,086 Mod ✭✭✭✭


    I have created a toggle button with different text for off/on:
    <ToggleButton
            android:id="@+id/PTT_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="pushtotalk"
            android:text="@string/ptt" 
            android:textOn="Push To Talk On"
            android:textOff="Push To Talk Off"/>
    
                      ...
    
    
    	public void pushtotalk(View view) {  
    	   final boolean on = ((ToggleButton) view).isChecked();
    	    
    	    new Thread(new Runnable() {         
    	        @Override
    	        public void run() {
    	            try {
    	            	Instrumentation inst = new Instrumentation();
    	            	if (on)
    	            	    {		            	
    		 inst.sendKeyDownUpSync(KeyEvent.KEYCODE_NUMPAD_MULTIPLY);
    		 Thread.sleep(500);
    		 inst.sendKeyDownUpSync(KeyEvent.KEYCODE_9);	
    			//etc
          
    
    When the toggle is off the button looks ok, however when I toggle on the light blue appears outside the box, what is happening here? Just a default background.

    AY145.png


    No matter what size I make the button this weird blue background stretches along with it,


Comments

  • Registered Users Posts: 644 ✭✭✭Freddio


    is the toggle button within a view that is constraining it?

    is @string/ptt non empty?


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,086 Mod ✭✭✭✭Tar.Aldarion


    I have the toggleButton in a layout and programatically in the main activity class, it's just the method that is posted above. I don't know what ramifications are of a view constraining something (ie what constraining it means here)? How might this affect it.

    I am editing sipdroid and stuck in that button: https://play.google.com/store/apps/details?id=org.sipdroid.sipua&hl=en https://code.google.com/p/sipdroid/ I believe this is the unedited file: https://code.google.com/p/sipdroid/source/browse/trunk/res/layout/sipdroid.xml?r=608
    Yeah the string is non empty. Also in the mean time I'll just make a fresh project with a toggle button and try to reproduce.


  • Registered Users Posts: 644 ✭✭✭Freddio


    It looks like the layout that wraps your button needs to have its dimensions adjusted.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,086 Mod ✭✭✭✭Tar.Aldarion


    Seems to be something like that, I'll try to adjust it now and see does it fix it, I don't know anything about absoluteLayout.
    Here is the code:
    <?xml version="1.0" encoding="utf-8"?>
    <AbsoluteLayout
    android:id="@+id/top_lvl_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    
       <FrameLayout android:id="@+id/mainFrame"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:paddingTop="10dip"
            android:paddingLeft="6dip"
            android:paddingRight="6dip"
            >
    
            <!-- (1) inCallPanel: the main set of in-call UI elements -->
            <RelativeLayout android:id="@+id/inCallPanel"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            >
    
                <!-- Slide hints: if the "sliding card" feature is enabled,
                     one or the other of these is visible at any given moment
                     (see updateCardSlideHints()). -->
    
                <!-- Slide hint and arrow *above* the main body of the card,
                     shown when the card is in the *bottom* position. -->
                <!-- This hint's position onscreen is static: the Y value is set
                     so that the hint will be visible just above the top edge of
                     the CallCard when the CallCard is in the "bottom" position.
                     The resources here describe the portrait mode layout; see
                     InCallScreen.ConfigurationHelper.applyConfigurationToLayout()
                     for the differences in landscape mode. -->
                <LinearLayout android:id="@+id/slideUp"
                              android:orientation="vertical"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:layout_alignParentBottom="true"
                              android:background="@null"
                              android:visibility="gone"
                              >
                    <TextView android:id="@+id/slideUpHint"
                              android:layout_gravity="center_horizontal"
                              android:gravity="center_horizontal"
                              android:textAppearance="?android:attr/textAppearanceMedium"
                              android:textColor="?android:attr/textColorSecondary"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content"
                              />
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:src="@android:drawable/arrow_up_float"
                        />
                    
                </LinearLayout>
    
                <!-- Slide hint and arrow *below* the main body of the card,
                     shown when the card is in the *top* position. -->
                <!-- This hint's position onscreen is static: the Y value is set
                     so that the hint will be visible just below the bottom edge of
                     the CallCard when the CallCard is in the "top" position.
                     The resources here describe the portrait mode layout; see
                     InCallScreen.ConfigurationHelper.applyConfigurationToLayout()
                     for the differences in landscape mode. -->
                <LinearLayout android:id="@+id/slideDown"
                              android:orientation="vertical"
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:layout_alignParentTop="true"
                               android:background="@null"
                              android:visibility="gone"
                              >
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:src="@android:drawable/arrow_down_float"
                        />
                    <TextView
                        android:id="@+id/slideDownHint"
                        android:layout_gravity="center_horizontal"
                        android:gravity="center_horizontal"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="?android:attr/textColorSecondary"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        />                
                    <TextView
                        android:id="@+id/stats"
                        android:layout_gravity="center_horizontal"
                        android:gravity="center_horizontal"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="?android:attr/textColorSecondary"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        />
                   <TextView
                        android:id="@+id/codec"
                        android:layout_gravity="center_horizontal"
                        android:gravity="center_horizontal"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="?android:attr/textColorSecondary"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        />
                </LinearLayout>
    
            </RelativeLayout>  <!-- End of inCallPanel -->
    
        </FrameLayout>  <!-- End of mainFrame -->
        
        <!-- The sliding drawer control containing the DTMF dialer.  This has been
             moved so that it is a sibling of mainFrame, instead of being a child.
             Doing so allows us to expand to the full width of the screen, instead
             of being confined to the mainFrame's layout -->
        <SlidingDrawer
            android:id="@+id/dialer_container"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
    
            android:topOffset="5px"
            android:bottomOffset="7px"
            android:handle="@+id/dialer_tab"
            android:content="@+id/dtmf_dialer"
    		android:allowSingleTap="false">
    		
           <ImageButton
               android:id="@id/dialer_tab"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_dialpad_tray"
               android:background="@drawable/tray_handle_normal"/>
    
            <include
                layout="@layout/dtmf_twelve_key_dialer"
                android:id="@id/dtmf_dialer"/>
    
        </SlidingDrawer>
    
      
        <ToggleButton
    		    android:id="@+id/PTT_button2"
    		    android:layout_width="wrap_content"
    		    android:layout_height="wrap_content"
    		    android:onClick="pushtotalk2"
    		    android:text="@string/ptt2" 
    		    android:layout_x="20dp"
            android:layout_y="400dp"
    		    android:textOn="Push To Talk On"
    			android:textOff="Push To Talk Off"/>      
        
          <EditText
            android:id="@+id/editText1"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_x="150dp"
            android:layout_y="400dp"
            android:ems="10" >
      
          
    		
            <requestFocus />
        </EditText>
        
    </AbsoluteLayout>
    


Advertisement