老司機(jī)來幫幫忙啊 今天做計算器發(fā)現(xiàn)的一個問題
自己做的計算器?思路跟老師差不多但是沒有設(shè)置按鈕參數(shù)都是用權(quán)重來做的??代碼如下;
<LinearLayout
??????????????????? android:layout_width="fill_parent"
??????????????????? android:layout_height="wrap_content"
??????????????????? android:orientation="horizontal"
??????????????????? android:weightSum="3"
??????????????????? android:layout_marginTop="20dp" >
??????????????????? <Button
??????????????????????? android:id="@+id/btn_0"
??????????????????????? android:layout_width="fill_parent"
??????????????????????? android:layout_height="wrap_content"
?????????????????????? android:layout_weight="1"
??????????????????????? android:gravity="bottom|right"
??????????????????????? android:text="0" />
??????????????????? <Button
??????????????????????? android:id="@+id/btn_point"
??????????????????????? android:layout_width="fill_parent"
??????????????????????? android:layout_height="wrap_content"
??????????????????????? android:layout_weight="2"
??????????????????????? android:gravity="bottom|right"
??????????????????????? android:text="." />
那么問題來了?為啥0?和.權(quán)重設(shè)置和界面顯示出來的相反????
2017-02-09
你缺了關(guān)于weight的知識,不知道設(shè)置了weight的視圖是如何計算寬高的,所以才會弄不明白
慕課網(wǎng)下面的這課,你看完就能解決這個問題了
2-1 Android面試解密-Layout_w...(10:27)
2017-02-09
試試把這兩個Button的layout_width設(shè)置為0
2017-02-09