小编812*_*621的帖子

如何以编程方式设置layout_alignParentRight ="false"?

如何以android:layout_alignParentRight="false"编程方式设置?我可以true通过此代码将其设置为但我想以false编程方式将其设置为:

RelativeLayout.Layoutparams params =
(RelativeLayout.LayoutParams)myView.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
button.setLayoutParams(params);
Run Code Online (Sandbox Code Playgroud)

有一个方法removeRule(int)但它被添加(API级别17).我想在API级别7或8中使用类似的东西.

android android-relativelayout android-layoutparams

14
推荐指数
1
解决办法
1万
查看次数

为对话框创建阴影

我想为我的自定义对话框创建一个阴影是可能的吗?

GhazalActivity.public void viewShareMenu() {
        Dialog share=new Dialog(this,R.style.shareDialogStyle);
        share.setContentView(R.layout.share_popup_layout);
        LayoutParams params = share.getWindow().getAttributes();
        params.y = this.getResources().getDimensionPixelSize(R.dimen.topbar_height);
        params.gravity=(Gravity.RIGHT|Gravity.TOP);
        share.getWindow().setAttributes(params);
        share.show();
}
Run Code Online (Sandbox Code Playgroud)

styles.xml:

<style name="shareDialogStyle" parent="android:style/Theme.Dialog">
    <item name="android:windowBackground">@color/transparent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:fadeEnabled">true</item>
    <item name="android:fadeDuration">1500</item>
    <item name="android:shadowColor">@color/temp</item>
    <item name="android:shadowDx">0</item>
    <item name="android:shadowDy">5</item>
    <item name="android:shadowRadius">10</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

share_popup_layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="150dip"
    android:background="@color/bg_Ghazal_share_menu"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        style="@style/shareDialogButtons"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这样做有什么解决方案吗?

android android-ui android-layout

4
推荐指数
1
解决办法
9346
查看次数