Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Get Screen Size Pixels per Inch Android example

The exact physical pixels per inch of the screen
Get size of pixel
Get DPI
Get count of pixels per inch

        float mXDpi;
        float mYDpi;
           DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            mXDpi = metrics.xdpi; // The exact physical pixels per inch of the screen in the X dimension. 
            mYDpi = metrics.ydpi;
          float  mMetersToPixelsX = mXDpi / 0.0254f; // 1 inch == 0.0254 metre
          float  mMetersToPixelsY = mYDpi / 0.0254f;



396LW NO topic_id




AD

Další témata ....(Topics)


348

Android Studio bug versioncode versionname signed apk issue | android-studio-bug-versioncode-versionname-signed-apk-issue


If you change android:versionCode="224" and android:versionName="2.2.4" in AndroidManifest.xml you have to change this in build.gradle file too.
Click on build.gradle in package explorer tree change your new version name and code:


  defaultConfig {
        applicationId "cz.okhelp.pocasiwidget"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 224
        versionName "2.2.4"
    }
172

Custom View Android Basic Example | custom-view-android-basic-example


Activity.java

public class A extends Activity{
	Bitmap bm;
	 TouchImageView touch;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 setContentView(R.layout.main);
		 
		 bm = BitmapFactory.decodeResource(getResources(), R.drawable.chinese_sky_map);
 		 touch =  (TouchImageView)findViewById(R.id.myImageView);
	  touch.setImageBitmap(bm);
		 
	}
}


\res\layout\main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <cz.okhelp.TouchImageView.TouchImageView
        android:id="@+id/myImageView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        
        />

</LinearLayout>



location TouchImageView\src\cz\okhelp\TouchImageView\TouchImageView.java

public class TouchImageView extends ImageView {


    Context context;

// constructor wihtout using  *.xml file
//    public TouchImageView(Context context) {
//        super(context);
// }

// constructor with xml file
    public TouchImageView(Context context, AttributeSet attrs)
    {
      super(context, attrs);
      super.setClickable(true);
        this.context = context;
  }
}

380

Android Fragment Examples | android-fragment-examples


Code look up at the Api Demos

android_fragments arguments attributes - three fragments on screen
android/android_fragments_arguments.png

android_fragments_alert_dialog
android/android_fragments_alert_dialog.png

android_fragments_context_menu
android/android_fragments_context_menu.png

android_fragments_custom_animation
android/android_fragments_custom_animation.png

android_fragments_dialog
android/android_fragments_dialog.png

android_fragments_dialog_or_activity
android/android_fragments_dialog_or_activity.png

fragment_hide_show
android/fragment_hide_show.png

fragment_layout
android/fragment_dialog.png

fragments_list_array
android/fragments_list_array.png

fragment_menu
android/fragment_menu.png

android_fragments_get_result_from_fragment and tabs in two rows
android/android_fragments_get_result_from_fragment.png

android_fragments_recive_result
android/android_fragments_recive_result.png

android_fragments_stack
android/android_fragments_stack.png

fragment_tabs
android/fragment_tabs.png





269

How to Add Home Screen Widgets on Your Android Phone | how-to-add-home-screen-widgets-on-your-android-phone


Long press by finger on screen
From dialogue select Widgets
Select your widget
Put your widget on the screen

Video tutorial - to add home screen widgets - Android 2.1