• 3
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I want to set property "Layout to right of" of control at runtime in android. Actually I want to adjust controls when screen changes orientation.

      • 1
    • The preferred way to "adjust controls when screen changes orientation" is to use two separate layout XML files, one for portrait (typically in res/layout/) and one for landscape (typically in res/layout-land/).

You can do something like this:

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.RIGHT_OF, view.getId());
  • 88
Reply Report

If you define a new LayoutParams, you lose other rules.

So if you just want to change or add a rule, do this:

 RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();
 params.addRule(RelativeLayout.RIGHT_OF, targetView.getId());
 view.setLayoutParams(params);
  • 5
Reply Report