고객이 앱에 내장 된 눈금자를 사용하여 특정 도구를 다른 도구를 사용하지 않고 측정 할 수있게하려고합니다. 눈금자를 배치 할 때 을 단위로 사용하면 대부분의 테스트 장치에서 정상적으로 작동합니다. 일부 장치는 인치 단위로 부정확하게 표시됩니다 때문 DP이에 대신 사용되어야하지만 안드로이드 스튜디오 나에게 경고합니다. Amazon Fire 7 인치 태블릿에서 테스트 할 때 해시 표시가 너무 많이 떨어져 있습니다. 나의 이해는 160dp가 항상 1 인치와 같아야한다. 그래서 나는 각각 1 인치와 2 인치 해시 마크를 위해 160dp와 320dp로 전환을 시도한다. 이번에는 해시 표시가 너무 가깝습니다. 아래의 스크린 샷을 참조하십시오. 검은 색 표시는 인치를 사용합니다. 빨간색 표시는 dp를 사용하고 있습니다. 올바른 크기는 이며, 검은 색과 빨간색 표시는입니다.일부 타블렛에서 inch/dp 값이 잘못됨
모든 장치에서 올바른 인치 값을 지정하거나 변환하려면 어떻게해야합니까? XML로 모든 값을 지정하는 것을 선호하지만 Java 코드를 사용하여 필요에 따라 레이아웃을 조정할 의향이 있습니다. 또한, 주어진 장치에서 인치 단위가 올바른지 알아내는 프로그램 방식이 있습니까?
도움 주셔서 감사합니다. 여기
내 코드입니다 : 난 그냥 XML로이 문제를 해결하기 위해 어떤 방법이 생각하지 않습니다<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/one_inch_left"
android:layout_width="@dimen/ruler_hash_width"
android:layout_height="1px"
android:layout_marginTop="1in"
android:background="@color/solid_black"
app:layout_constraintTop_toBottomOf="parent"/>
<View
android:id="@+id/two_inch_left"
android:layout_width="@dimen/ruler_hash_width"
android:layout_height="1px"
android:layout_marginTop="2in"
android:background="@color/solid_black"
app:layout_constraintTop_toBottomOf="parent"/>
<View
android:id="@+id/one_inch_left2"
android:layout_width="@dimen/ruler_hash_width"
android:layout_height="1px"
android:layout_marginTop="160dp"
android:background="@color/red_button_color"
app:layout_constraintTop_toBottomOf="parent"/>
<View
android:id="@+id/two_inch_left2"
android:layout_width="@dimen/ruler_hash_width"
android:layout_height="1px"
android:layout_marginTop="320dp"
android:background="@color/red_button_color"
app:layout_constraintTop_toBottomOf="parent"/>
</android.support.constraint.ConstraintLayout>