에 ViewGroup.LayoutParams 변환 할 수 없습니다에 게시 exampled :
How can I create a weekly calendar view for an Android Honeycomb application?
나는 XML 파일에 추가 한 번 마커 라인이 게시하는 현재 시간대에 있다고 가정합니다.유형 불일치 : 나는 다음 주간 일정을 프로그래밍하기 위해 노력하고있어 LinearLayout.LayoutParams
<LinearLayout
android:id="@+id/currentTimeMarkerLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="120dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="0dp" >
<View
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_weight="1" />
<View
android:id="@+id/currentTimeLineView"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="14"
android:background="@color/dark_blue" />
</LinearLayout>
이 LinearLayout
는 ScrollView
내부 RelativeLayout
와 둘 다 내부 : 내가 사용하는 것이 수행합니다.
int dipValue = 720; // we want to convert this dip value to pix
Resources r = getResources();
float pix = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
dipValue, r.getDisplayMetrics());
LinearLayout lay =(LinearLayout) findViewById(R.id.currentTimeMarkerLinearLayout);
LinearLayout.LayoutParams lp = lay.getLayoutParams();
lp.setMargins(0, (int) pix, 0, 0);
lay.setLayoutParams(lp);
그러나 나는 그것이 LinearLayout.LayoutParams
에 ViewGroup.LayoutParams
에서 변환 할 수 있음을 말해 lp = lay.getLayoutParams()
에 오류가 발생합니다 :
나는이 라인과 layout_margintTop
을 수정하여, 프로그램을 통해이 줄을 "이동"하는 것을 시도하고있다.
내가 뭘 잘못하고 있니?
대단히 감사합니다. Luksprog, 저는이 문제로 인해 많은 시간을 낭비합니다. Righ 지금은 아주 좋은 일하고있다! – mgrdiez