हाय सब मैंने अभी एक लिनियरलाउट के अंदर एक सूची दृश्य लागू किया है, लेकिन मुझे लाइनरलाइट की ऊंचाई को परिभाषित करने की आवश्यकता है (यह स्क्रीन ऊंचाई का 50% होना चाहिए)।एंड्रॉइड: लेआउट_हेइट स्क्रीन आकार का 50%
<LinearLayout
android:id="@+id/widget34"
android:layout_width="300px"
android:layout_height="235px"
android:orientation="vertical"
android:layout_below="@+id/tv_scanning_for"
android:layout_centerHorizontal="true">
<ListView
android:id="@+id/lv_events"
android:textSize="18sp"
android:cacheColorHint="#00000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_scanning_for"
android:layout_centerHorizontal="true">
</ListView>
</LinearLayout>
क्या यह संभव है?
मैंने बटन और एडिटटेक्स्ट के लिए कुछ ऐसा किया, लेकिन लेआउट पर काम नहीं कर रहा है।
//capture the size of the devices screen
Display display = getWindowManager().getDefaultDisplay();
double width = display.getWidth();
//my EditText will be smaller than full screen (80%)
double doubleSize = (width/5)*4;
int editTextSize = (int) doubleSize;
//define the EditText
userName = (EditText) this.findViewById(R.id.userName);
password = (EditText) this.findViewById(R.id.password);
//set the size
userName.setWidth(editTextSize);
password.setWidth(editTextSize);
धन्यवाद:
यह मेरा कोड है! :)
क्या आपने लीनियरलाउट के आसपास एक रिलेवेटिवआउट का उपयोग करने का प्रयास किया है और रिलेटिव लयआउट का आकार लिया है? –
क्या मैं रिलेवेटिवआउट ऊंचाई पैरामीटर में प्रतिशत दर्ज कर सकता हूं? –
कस्टम लेआउट पैराम का उपयोग करें: http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html RelativeLayout.setLayoutParams(): http://developer.android.com/reference/android/view/View के साथ .html # setLayoutParams% 28android.view.ViewGroup.LayoutParams% 29। प्रदर्शित करने के लिए ऊंचाई सेट करें .getHeight()/2 –