Accessing integer resources in xml

前端 未结 6 1447
醉酒成梦
醉酒成梦 2021-02-02 08:23

I have read this where found that how to access integer resources in java class but no docs for another resource.

Here is Resources at res/values/integers.xml

         


        
6条回答
  •  借酒劲吻你
    2021-02-02 08:59

    Finally I am able to access integer resource in java code and integer value as dimen in xml.

    
    
        20dip
        20
    
    

    In xml file:-

     
    

    In java file:-

    EditText mUsername = (EditText) this.findViewById(R.id.user_name);
    //int padding = this.getResources().getInteger(R.integer.input_field_padding);
    int padding = (int) this.getResources().getDimension(R.dimen.input_field_padding);
    mUsername.setPadding(padding, padding, padding, padding);
    

提交回复
热议问题