저는 main.xml TitlePageIndicator와 ViewPager에 있습니다. RelativeLayout의 맨 아래에 admob (LinearLayout에 오른쪽)을 추가하고 싶습니다. 어떻게해야합니까?RelativeLayout의 하단에 뷰를 동적으로 추가합니다.
로그를 실행하면 로그에 오류에 대해 아무 것도 표시되지 않지만 admob은 보이지 않으므로 볼 수 없습니다. (ViewPager에 특정 크기를 설정하려고했기 때문에 admob이 화면 외부에있는 것처럼 보입니다.) ViewPager에 특정 크기를 설정하고 싶지 않습니다. (화면 크기가 다르기 때문에) 감사합니다.
내 main.xml에는 다음과 같습니다
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/indicator"/>
<LinearLayout
android:id="@+id/for_ads"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/viewpager"/>
</RelativeLayout>
UPD. ,
RelativeLayout rLayout = (RelativeLayout)findViewById(R.id.yourRelativeId);
그런 다음 개체에 대한 일부의 LayoutParams을 생성 (이 경우 : 내가이 answer을 사용 를 해결하고 당신이 그것을 참조 할 경우
은, 몹이 내 다른 UI를 포함, 응답에 대한 –
감사 객체, 나는 다만, 당신이 다른보기 이하로 할 경우,이 :) –
해결 : rLParams. addRule (RelativeLayout.BELOW, viewtoBeBelow.getId()); 하지만 아래보기가 아래쪽으로 확장되면 광고보기를 볼 수 없게됩니다. 즉, 아래 대신에 광고보기 위에 있어야하는보기의 LayoutParams를 변경해야합니다. addRule (RelativeLayout.ABOVE, yourAdView.getId()); setID (someInteger)를 사용하여 adview에 대한 ID를 설정했는지 확인하십시오. 또는 뷰를 상대적으로 배치 할 수 없습니다. – Guardanis