Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:&quo

code to get Height of TextView(Here using this code we can also get Number of lines ,Height and width of View) Android..

ViewHightActivity.java:-
package org.example.ViewHight;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ViewHightActivity extends Activity{
     
     TextView textMyTextView, textViewWidth, textViewHeight;
     Button myButton;
     
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
           textMyTextView = (TextView)findViewById(R.id.mytextview);
           textViewWidth = (TextView)findViewById(R.id.viewwidth);
           textViewHeight = (TextView)findViewById(R.id.viewheight);
           myButton = (Button)findViewById(R.id.mybutton);
          
           myButton.setOnClickListener(new Button.OnClickListener(){
   
       @Override
       public void onClick(View arg0) {
        // TODO Auto-generated method stub
        updateSizeInfo();
       }});
       }
      
   
     @Override
     public void onWindowFocusChanged(boolean hasFocus) {
      // TODO Auto-generated method stub
      super.onWindowFocusChanged(hasFocus);
      updateSizeInfo();
     }
   
   
     private void updateSizeInfo(){
       
         System.out.println("===width==="+textViewHeight.getWidth());
         System.out.println("===Hight==="+textViewHeight.getHeight());
   
        //textViewWidth.setText(String.valueOf("Button's Width(pixels): " + myButton.getWidth()));
        //textViewHeight.setText(String.valueOf("Button's Height(pixels): " + myButton.getHeight()));
       }
   
    }

main.xml:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
<TextView
   android:id="@+id/mytextview"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="@string/hello"
   />
<Button
   android:id="@+id/mybutton"
   android:layout_width="200px"
   android:layout_height="wrap_content"
   android:text="Check my size"
   />
<TextView
   android:id="@+id/viewwidth"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   />
<TextView
   android:id="@+id/viewheight"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="jhasdhja ld lfjklds ljfl dsljdsl jlfjl ljlkas jdljas ljd asl d jlasjld las jljkljal jd aljdasjl jldjasl jlj"
   android:textSize="20dip"
   android:singleLine="false"
   />
</LinearLayout>

Comments