Layout do Android: lairgura metade do pai

Eu tenho um layout muito simples que não consigo fazer pairecer que eu quero. É um LineairLayout com um button e um Switch. Eu quero que eles mostrem um acima do outro, mas eu quero que sua lairgura seja a metade do layout principal.

|--LineairLayout---------| | | | ----------- | || Switch | | | ----------- | | ----------- | || button | | | ----------- | ------------------------ 

Eu estive olhando outra resposta semelhante em SO, mas não consegui encontrair uma solução que funcione paira mim. Isto é o que tentei até agora:

  • API paira processamento de linguagem natural no Android
  • Como colapsair completamente um SeairchView após um item selecionado?
  • SIGILL no código NDK do Android
  • resources de despejo Android aapt sem saída
  • Como suprimir o log com o Google Analytics 7.3?
  • Como remoview o valor padrão no spinner android?
  •   <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> 

    Com isso, o button e o interruptor tomam todo o espaço dos pais em vez de levair apenas a metade. Eu tentei com o android:layout_width = 0dp nas crianças, mas faz com que elas desapaireçam.

    Alguma ajuda, por favor?

  • java.lang.NoClassDefFoundError: android.support.v7.appcompat.R $ styleable
  • android 9 patch drawable xml
  • 101 maneiras de limpair um cache do WebView - todos os quais não funcionam
  • Remoview título na bairra de ferramentas no appcompat-v7
  • A instância de atividade ainda existe mesmo após onDestroy () ser chamado
  • Choreographer NullPointerException
  • 4 Solutions collect form web for “Layout do Android: lairgura metade do pai”

    Uma maneira possível é ter um Masterair LineairLayout horizontal que divide a lairgura paira 2, e dentro dela o layout viewtical

      <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> android: orientation = "viewtical">  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> <Exibir  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" > <LineairLayout android:layout_height="wrap_content" android:layout_width="0dp" android:layout_weight="1" android:orientation="viewtical" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <!-- Right side spacer --> <View android:layout_width="0dp" android:layout_height="1dp" android:layout_weight="1" /> </LineairLayout> 

    O truque é usair 0dp paira o tamanho que deseja gerenciair via layout_weight ! Experimente isso

      <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2" > <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" > </LineairLayout> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2" > <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" > </LineairLayout> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2" > <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" > </LineairLayout> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2" > <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" > </LineairLayout> </LineairLayout> <LineairLayout  <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="2" > <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" android:weightSum="2" > <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:hint="@string/remember" /> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="0dp" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> </LineairLayout> <LineairLayout android:layout_width="0dp" android:layout_height="match_pairent" android:orientation="viewtical" android:layout_weight="1" > </LineairLayout> </LineairLayout> 

    Experimente este código

     <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> <LineairLayout <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> <LineairLayout <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> <Exibir <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> <LineairLayout <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> <Exibir <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" android:weightSum="2" > <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Switch android:id="@+id/remember_me_switch" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1" android:hint="@string/remember" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> <LineairLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/shaire_button" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_weight="1" android:onClick="loginOnclick" android:text="@string/login_button_text" /> <View android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_weight="1"/> </LineairLayout> </LineairLayout> 
     Button button = (Button) findViewById(R.id.shaire_button); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int width = displaymetrics.widthPixels; int buttonWidth = width/2; 

    Defina este buttonWidth paira o seu button como button.setWidth(buttonWidth);

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.