android studio linearlayout 自动变,Android Studio更改LinearLayout大小

我想在我的程序中更改线性布局的大小,而不是xml文件本身。我是一名初学者,也想在方法之外声明我的变量(public),并在方法中初始化它,就像我用EditText和LinearLayout所做的那样。Android Studio更改LinearLayout大小

我尝试了这种方式,但它说:

Error:(47, 81) error: incompatible types: android.view.ViewGroup.LayoutParams cannot be converted to android.widget.LinearLayout.LayoutParams

但我不知道如何处理此错误:(

到目前为止我的代码:

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

public EditText input_chat;

public LinearLayout layout_chat_input;

public LinearLayout.LayoutParams layout_chat_input_params;

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Toast.makeText(getApplicationContext(),"onCreate",Toast.LENGTH_SHORT).show();

input_chat = (EditText) findViewById(R.id.input_chat);

layout_chat_input = (LinearLayout) findViewById(R.id.layout_chat_input);

layout_chat_input_params = new LinearLayout.LayoutParams(layout_chat_input.getLayoutParams());

input_chat.addTextChangedListener(new TextWatcher()

{

public void onTextChanged(CharSequence s, int start, int before, int count)

{

if (input_chat.getLineCount() > 0 && input_chat.getLineCount() < 5)

{

layout_chat_input_params = layout_chat_input.getLayoutParams();

layout_chat_input.setLayoutParams();

}

}

public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

public void afterTextChanged(Editable s) {}

});

}

}

2017-10-06

Leschge

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值